From: <aca...@us...> - 2007-07-26 16:38:50
|
Revision: 664 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=664&view=rev Author: acarboni Date: 2007-07-26 09:38:51 -0700 (Thu, 26 Jul 2007) Log Message: ----------- Fixed bug with data upload Modified Paths: -------------- trunk/docs/changes.txt trunk/web/geonetwork/WEB-INF/lib/jeeves.jar Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-07-26 12:13:00 UTC (rev 663) +++ trunk/docs/changes.txt 2007-07-26 16:38:51 UTC (rev 664) @@ -51,6 +51,9 @@ - Fixed bug with MEF import: private data was not imported +- Fixed bug with data upload: if the browser was IE and the server was running + on linux the upload file name contained the file path + ================================================================================ === === GeoNetwork 2.1.0 beta4 : List of changes Modified: trunk/web/geonetwork/WEB-INF/lib/jeeves.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <blu...@us...> - 2007-07-27 15:51:35
|
Revision: 674 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=674&view=rev Author: bluenetdevteam Date: 2007-07-27 08:51:32 -0700 (Fri, 27 Jul 2007) Log Message: ----------- Fixes for parsing and editing 19139 schema Modified Paths: -------------- trunk/src/org/fao/geonet/kernel/DataManager.java trunk/src/org/fao/geonet/kernel/EditLib.java trunk/src/org/fao/geonet/kernel/schema/AttributeEntry.java trunk/src/org/fao/geonet/kernel/schema/ComplexContentEntry.java trunk/src/org/fao/geonet/kernel/schema/ComplexTypeEntry.java trunk/src/org/fao/geonet/kernel/schema/ElementEntry.java trunk/src/org/fao/geonet/kernel/schema/GroupEntry.java trunk/src/org/fao/geonet/kernel/schema/Logger.java trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java trunk/src/org/fao/geonet/kernel/schema/MetadataType.java trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java trunk/src/org/fao/geonet/kernel/schema/SimpleTypeEntry.java trunk/web/geonetwork/xsl/metadata-iso19139.xsl trunk/web/geonetwork/xsl/metadata.xsl Modified: trunk/src/org/fao/geonet/kernel/DataManager.java =================================================================== --- trunk/src/org/fao/geonet/kernel/DataManager.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/DataManager.java 2007-07-27 15:51:32 UTC (rev 674) @@ -727,11 +727,18 @@ if (!childName.equals("")) { // or element - Element orChild = new Element(childName, el.getNamespace()); - child.addContent(orChild); + String uChildName = editLib.getUnqualifiedName(childName); + String prefix = editLib.getPrefix(childName); + String ns = editLib.getNamespace(childName,md); + if (prefix.equals("")) { + prefix = editLib.getPrefix(el.getName()); + ns = editLib.getNamespace(el.getName(),md); + } + Element orChild = new Element(uChildName,prefix,ns); + child.addContent(orChild); - //--- add mandatory sub-tags - editLib.fillElement(schema, orChild); + //--- add mandatory sub-tags + editLib.fillElement(schema, child, orChild); } } md = updateFixedInfo(schema, id, md, dbms); @@ -961,10 +968,26 @@ if (el == null) throw new IllegalStateException("Element not found at ref = " + ref); - if (attr != null) - { - if (el.getAttribute(attr) != null) - el.setAttribute(new Attribute(attr, val)); + if (attr != null) { +// The following work-around decodes any attribute name that has a COLON in it +// The : is replaced by the word COLON in the xslt so that it can be processed +// by the XML Serializer when an update is submitted - the only situation +// where this is known to occur is in the gml schema (eg. gml:id) - a better +// solution may be required + Integer indexColon = attr.indexOf("COLON"); + if (indexColon != -1) { + String prefix = attr.substring(0,indexColon); + String localname = attr.substring(indexColon + 5); + String namespace = editLib.getNamespace(prefix+":"+localname,md); + Namespace attrNS = Namespace.getNamespace(prefix,namespace); + if (el.getAttribute(localname,attrNS) != null) { + el.setAttribute(new Attribute(localname,val,attrNS)); + } +// End of work-around + } else { + if (el.getAttribute(attr) != null) + el.setAttribute(new Attribute(attr, val)); + } } else { @@ -996,6 +1019,10 @@ if (version != null && !editLib.getVersion(id).equals(version)) return false; + //--- make sure that any lingering CHOICE_ELEMENTS are replaced with their + //--- children + editLib.replaceChoiceElements(md); + String schema = getMetadataSchema(dbms, id); md = updateFixedInfo(schema, id, md, dbms); @@ -1452,14 +1479,18 @@ public static void setNamespacePrefix(Element md) { - //--- if the metadata has no namespace, we must skip this phase + //--- if the metadata has no namespace or already has a namespace then + //--- we must skip this phase - if (md.getNamespace() == Namespace.NO_NAMESPACE) - return; + Namespace ns = md.getNamespace(); + // System.out.println("DM: Namespace prefix is '"+md.getNamespacePrefix()+"'"); // DEBUG + if (ns == Namespace.NO_NAMESPACE || (!md.getNamespacePrefix().equals(""))) + return; + //--- set prefix for iso19139 metadata - Namespace ns = Namespace.getNamespace("gmd", md.getNamespace().getURI()); + ns = Namespace.getNamespace("gmd", md.getNamespace().getURI()); setNamespacePrefix(md, ns); } Modified: trunk/src/org/fao/geonet/kernel/EditLib.java =================================================================== --- trunk/src/org/fao/geonet/kernel/EditLib.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/EditLib.java 2007-07-27 15:51:32 UTC (rev 674) @@ -30,6 +30,7 @@ import java.util.*; import org.fao.geonet.kernel.schema.*; import org.jdom.*; +import jeeves.utils.Xml; import java.io.File; import org.fao.geonet.constants.Edit; @@ -127,6 +128,7 @@ enumerateTree(md, 1); expandTree(schema, getSchema(schema), md); + //System.out.println("MD after editing infomation:\n" + jeeves.utils.Xml.getString(md)); return version; } @@ -157,9 +159,9 @@ * should be empty. */ - public void fillElement(String schema, Element md) + public void fillElement(String schema, Element parent, Element md) throws Exception { - fillElement(getSchema(schema), getSchemaSuggestions(schema), md); + fillElement(getSchema(schema), getSchemaSuggestions(schema), parent, md); } //-------------------------------------------------------------------------- @@ -221,7 +223,7 @@ //-------------------------------------------------------------------------- - public Element addElement(String schema, Element el, String qname) + public Element addElement(String schema, Element el, String qname) throws Exception { // System.out.println("#### in addElement()"); // DEBUG @@ -231,23 +233,32 @@ String name = getUnqualifiedName(qname); String ns = getNamespace(qname, el); String prefix = getPrefix(qname); + String parentName = getParentNameFromChild(el); + -// System.out.println("#### - child name = " + name); // DEBUG -// System.out.println("#### - child namespace = " + ns); // DEBUG -// System.out.println("#### - child prefix = " + prefix); // DEBUG + // System.out.println("#### - parent name = " + parentName); // DEBUG + // System.out.println("#### - child name = " + name); // DEBUG + // System.out.println("#### - child namespace = " + ns); // DEBUG + // System.out.println("#### - child prefix = " + prefix); // DEBUG + List childS = el.getChildren(); + if (childS.size() > 0) { + Element elChildS = (Element)childS.get(0); + // System.out.println("#### - child text = " + elChildS.getName()); // DEBUG + } + Element child = new Element(name, prefix, ns); MetadataSchema mdSchema = getSchema(schema); SchemaSuggestions mdSugg = getSchemaSuggestions(schema); - String typeName = mdSchema.getElementType(el.getQualifiedName()); + String typeName = mdSchema.getElementType(el.getQualifiedName(),parentName); -// System.out.println("#### - type name = " + typeName); // DEBUG + // System.out.println("#### - type name = " + typeName); // DEBUG MetadataType type = mdSchema.getTypeInfo(typeName); -// System.out.println("#### - metadata tpe = " + type); // DEBUG + // System.out.println("#### - metadata tpe = " + type); // DEBUG //--- collect all children, adding the new one at the end of the others @@ -257,7 +268,7 @@ { List list = getChildren(el, type.getElementAt(i)); -// System.out.println("#### - children of type " + type.getElementAt(i) + " list size = " + list.size()); // DEBUG + // System.out.println("#### - children of type " + type.getElementAt(i) + " list size = " + list.size()); // DEBUG for(int j=0; j<list.size(); j++) children.add(list.get(j)); @@ -274,7 +285,7 @@ el.addContent((Element) children.get(i)); //--- add mandatory sub-tags - fillElement(mdSchema, mdSugg, child); + fillElement(mdSchema, mdSugg, el, child); return child; } @@ -323,25 +334,27 @@ //-------------------------------------------------------------------------- - private void fillElement(MetadataSchema schema, SchemaSuggestions sugg, Element md) + private void fillElement(MetadataSchema schema, SchemaSuggestions sugg, + Element parent, Element md) throws Exception { -// System.out.println("#### entering fillElement()"); // DEBUG + //System.out.println("#### entering fillElement()"); // DEBUG String elemName = md.getQualifiedName(); + String parentName = parent.getQualifiedName(); -// System.out.println("#### - elemName = " + elemName); // DEBUG -// System.out.println("#### - isSimpleElement(" + elemName + ") = " + schema.isSimpleElement(elemName)); // DEBUG + //System.out.println("#### - elemName = " + elemName); // DEBUG + //System.out.println("#### - isSimpleElement(" + elemName + ") = " + schema.isSimpleElement(elemName,parentName)); // DEBUG - if (schema.isSimpleElement(elemName)) + if (schema.isSimpleElement(elemName,parentName)) return; - MetadataType type = schema.getTypeInfo(schema.getElementType(elemName)); + MetadataType type = schema.getTypeInfo(schema.getElementType(elemName,parentName)); -// System.out.println("#### - type:"); // DEBUG -// System.out.println("#### - name = " + type.getName()); // DEBUG -// System.out.println("#### - # attributes = " + type.getAttributeCount()); // DEBUG -// System.out.println("#### - # elements = " + type.getElementCount()); // DEBUG -// System.out.println("#### - # isOrType = " + type.isOrType()); // DEBUG + //System.out.println("#### - type:"); // DEBUG + //System.out.println("#### - name = " + type.getName()); // DEBUG + //System.out.println("#### - # attributes = " + type.getAttributeCount()); // DEBUG + //System.out.println("#### - # elements = " + type.getElementCount()); // DEBUG + //System.out.println("#### - # isOrType = " + type.isOrType()); // DEBUG //----------------------------------------------------------------------- //--- handle attributes @@ -350,8 +363,8 @@ { MetadataAttribute attr = type.getAttributeAt(i); -// System.out.println("#### - " + i + " attribute = " + attr); // DEBUG -// System.out.println("#### - required = " + attr.required); // DEBUG + //System.out.println("#### - " + i + " attribute = " + attr.name); // DEBUG + //System.out.println("#### - required = " + attr.required); // DEBUG if (attr.required) { @@ -360,8 +373,17 @@ if (attr.defValue != null) value = attr.defValue; - String uname = getUnqualifiedName(attr.name); // FIXME: only allow unqualified attributes - md.setAttribute(new Attribute(uname, value)); + String uname = getUnqualifiedName(attr.name); + String ns = getNamespace(attr.name, md); + String prefix = getPrefix(attr.name); + // if the prefix is gml then we create the attribute with the + // appropriate namespace because gml types include ref'd attributes + // like gml:id - the others such as gmd etc don't include refs but + // define types that include attributes without namespace prefixes + if (prefix.equals("gml")) + md.setAttribute(new Attribute(uname, value, Namespace.getNamespace(prefix,ns))); + else + md.setAttribute(new Attribute(uname, value)); } } @@ -375,15 +397,22 @@ int minCard = type.getMinCardinAt(i); String childName = type.getElementAt(i); + // Now if the element has subs examine them and substitute the + // correct element based on the namespace of the root element + if (type.examineSubs(i)) { + childName = getSubstituteName(schema,childName,md); + //System.out.println("- childName has substituted = " + childName); + } + if (minCard > 0 || sugg.isSuggested(elemName, childName)) { - MetadataType elemType = schema.getTypeInfo(schema.getElementType(childName)); + MetadataType elemType = schema.getTypeInfo(schema.getElementType(childName,elemName)); //--- There can be 'or' elements with other 'or' elements inside them. //--- In this case we cannot expand the inner 'or' elements so the //--- only way to solve the problem is to avoid the creation of them - if (schema.isSimpleElement(childName) || !elemType.isOrType()) + if (schema.isSimpleElement(elemName, childName) || !elemType.isOrType()) { String name = getUnqualifiedName(childName); String ns = getNamespace(childName, md); @@ -392,7 +421,7 @@ Element child = new Element(name, prefix, ns); md.addContent(child); - fillElement(schema, sugg, child); + fillElement(schema, sugg, md, child); } } } @@ -447,30 +476,79 @@ } //-------------------------------------------------------------------------- + + private String getParentNameFromChild(Element child) { + String childName = child.getQualifiedName(); + String parentName = "root"; + Element parent = child.getParentElement(); + if (parent != null) { + parentName = parent.getQualifiedName(); + } + return parentName; + } + + //-------------------------------------------------------------------------- + /** Checks substitutions for element and returns substitute based on + * namespace prefix of the root + */ + private String getSubstituteName(MetadataSchema schema, String childQName, + Element md) + { + ArrayList subsNames = schema.getElementSubs(childQName); + if (subsNames == null) return childQName; + + // find root element, where namespaces *must* be declared + Element root = md; + while (root.getParent() != null && root.getParent() instanceof Element) root = (Element)root.getParent(); + String prefix = root.getNamespacePrefix(); + + for (int i = 0;i < subsNames.size();i++) { + String sub = (String) subsNames.get(i); + if (getPrefix(sub).equals(prefix)) return sub; + } + + return childQName; + + } + + //-------------------------------------------------------------------------- + /** Replace CHOICE_ELEMENTs with their children by enumerating the tree + */ + public void replaceChoiceElements(Element md) throws Exception + { + enumerateTree(md); + removeEditingInfo(md); + } + + + //-------------------------------------------------------------------------- /** Adds editing information to a single element */ private void expandElement(String schemaName, MetadataSchema schema, Element md) throws Exception { -// System.out.println("entering expandElement()"); // DEBUG + // System.out.println("entering expandElement()"); // DEBUG String elemName = md.getQualifiedName(); - String elemType = schema.getElementType(elemName); + String parentName = getParentNameFromChild(md); -// System.out.println("elemName = " + elemName); // DEBUG -// System.out.println("elemType = " + elemType); // DEBUG + // System.out.println("elemName = " + elemName); // DEBUG + // System.out.println("parentName = " + parentName); // DEBUG + String elemType = schema.getElementType(elemName,parentName); + // System.out.println("elemType = " + elemType); // DEBUG + Element elem = md.getChild(Edit.RootChild.ELEMENT, Edit.NAMESPACE); - addValues(schema, elem, elemName); + addValues(schema, elem, elemName, parentName); - if (schema.isSimpleElement(elemName)) + if (schema.isSimpleElement(elemName,parentName)) { -// System.out.println("is simple element"); // DEBUG + // System.out.println("is simple element"); // DEBUG return; } MetadataType type = schema.getTypeInfo(elemType); -// System.out.println("type is = " + type.getName()); // DEBUG + Boolean postProcessChoiceElements = false; if (!type.isOrType()) { @@ -478,42 +556,52 @@ { String childQName = type.getElementAt(i); -// System.out.println("- childName = " + childQName); // DEBUG - + // System.out.println("- childName = " + childQName); // DEBUG if (childQName == null) continue; // schema extensions cause null types; just skip + // Now if the element has subs examine them and substitute the + // correct element based on the namespace of the root element + if (type.examineSubs(i)) { + childQName = getSubstituteName(schema,childQName,md); + // System.out.println("- childName has substituted = " + childQName); + } + String childName = getUnqualifiedName(childQName); String childPrefix = getPrefix(childQName); String childNS = getNamespace(childQName, md); -// System.out.println("- name = " + childName); // DEBUG -// System.out.println("- prefix = " + childPrefix); // DEBUG -// System.out.println("- namespace = " + childNS); // DEBUG + // System.out.println("- name = " + childName); // DEBUG + // System.out.println("- prefix = " + childPrefix); // DEBUG + // System.out.println("- namespace = " + childNS); // DEBUG List list = md.getChildren(childName, Namespace.getNamespace(childNS)); if (list.size() == 0) { -// System.out.println("- no children of this type already present"); // DEBUG + // System.out.println("- no children of this type already present"); // DEBUG - Element newElem = createElement(schemaName, schema, childName, childPrefix, childNS); - if (i == 0) insertFirst(md, newElem); - else - { - String prevQName = type.getElementAt(i-1); - String prevName = getUnqualifiedName(prevQName); - String prevNS = getNamespace(prevQName, md); - insertLast(md, prevName, prevNS, newElem); - } + Element newElem = createElement(schemaName, schema, elemName, childQName, childPrefix, childNS); + if (i == 0) insertFirst(md, newElem); + else + { + String prevQName = type.getElementAt(i-1); + String prevName = getUnqualifiedName(prevQName); + String prevNS = getNamespace(prevQName, md); + insertLast(md, prevName, prevNS, newElem); + } } else { -// System.out.println("- " + list.size() + " children of this type already present"); // DEBUG -// System.out.println("- min cardinality = " + type.getMinCardinAt(i)); // DEBUG -// System.out.println("- max cardinality = " + type.getMaxCardinAt(i)); // DEBUG + // System.out.println("- " + list.size() + " children of this type already present"); // DEBUG + // System.out.println("- min cardinality = " + type.getMinCardinAt(i)); // DEBUG + // System.out.println("- max cardinality = " + type.getMaxCardinAt(i)); // DEBUG for(int j=0; j<list.size(); j++) { Element listChild = (Element) list.get(j); + + // IF this is a CHOICE_ELEMENT then we will replace it afterwards + // with its children + postProcessChoiceElements = true; Element listElem = listChild.getChild(Edit.RootChild.ELEMENT, Edit.NAMESPACE); if (j>0) @@ -526,16 +614,33 @@ listElem.setAttribute(new Attribute(Edit.Element.Attr.DEL, Edit.Value.TRUE)); } if (list.size() < type.getMaxCardinAt(i)) - insertLast(md, childName, childNS, createElement(schemaName, schema, childName, childPrefix, childNS)); + insertLast(md, childName, childNS, createElement(schemaName, schema, elemName, childQName, childPrefix, childNS)); } + } + +// Deals with CHOICE_ELEMENTs by replacing them with their children +// FIXME: must also copy up the geonet:element child so that minOccurs/maxOccurs +// are properly carried - this isn't a problem yet + if (postProcessChoiceElements) { + List list = md.getChildren(); + for (int i = 0;i < list.size();i++) { + Element listChild = (Element) list.get(i); + if (listChild.getName().indexOf("CHOICE_ELEMENT") != -1) { + // System.out.println("###### Replacing "+listChild.getName()); + List children = listChild.getChildren(); + Element child = (Element)children.get(0); + list.set(i,child.detach()); + } + } + } } addAttribs(type, md); } //-------------------------------------------------------------------------- - private String getUnqualifiedName(String qname) + public String getUnqualifiedName(String qname) { int pos = qname.indexOf(":"); if (pos < 0) return qname; @@ -544,7 +649,7 @@ //-------------------------------------------------------------------------- - private String getPrefix(String qname) + public String getPrefix(String qname) { int pos = qname.indexOf(":"); if (pos < 0) return ""; @@ -553,19 +658,32 @@ //-------------------------------------------------------------------------- - private String getNamespace(String qname, Element md) + public String getNamespace(String qname, Element md) { - // find root element, where namespaces *must* be declared - Element root = md; - while (root.getParent() != null && root.getParent() instanceof Element) root = (Element)root.getParent(); + // check the element first to see whether the namespace is + // declared locally + String result = checkNamespaces(qname,md); + if (result.equals("UNKNOWN")) { + // find root element, where namespaces *must* be declared + Element root = md; + while (root.getParent() != null && root.getParent() instanceof Element) root = (Element)root.getParent(); + result = checkNamespaces(qname,root); + } + return result; + } + + //-------------------------------------------------------------------------- + + public String checkNamespaces(String qname, Element md) + { // get prefix String prefix = getPrefix(qname); // loop on namespaces to fine the one corresponding to prefix - Namespace rns = root.getNamespace(); + Namespace rns = md.getNamespace(); if (prefix.equals(rns.getPrefix())) return rns.getURI(); - for (Iterator i = root.getAdditionalNamespaces().iterator(); i.hasNext(); ) + for (Iterator i = md.getAdditionalNamespaces().iterator(); i.hasNext(); ) { Namespace ns = (Namespace)i.next(); if (prefix.equals(ns.getPrefix())) return ns.getURI(); @@ -718,16 +836,16 @@ /** Create a new element for editing, adding all mandatory subtags */ - private Element createElement(String schemaName, MetadataSchema schema, String name, String prefix, String ns) throws Exception + private Element createElement(String schemaName, MetadataSchema schema, String parent, String qname, String childPrefix, String childNS) throws Exception { Element child = new Element(Edit.RootChild.CHILD, Edit.NAMESPACE); - child.setAttribute(new Attribute(Edit.ChildElem.Attr.NAME, name)); - child.setAttribute(new Attribute(Edit.ChildElem.Attr.PREFIX, prefix)); - child.setAttribute(new Attribute(Edit.ChildElem.Attr.NAMESPACE, ns)); + child.setAttribute(new Attribute(Edit.ChildElem.Attr.NAME, getUnqualifiedName(qname))); + child.setAttribute(new Attribute(Edit.ChildElem.Attr.PREFIX, getPrefix(qname))); + child.setAttribute(new Attribute(Edit.ChildElem.Attr.NAMESPACE, childNS)); - if (!schema.isSimpleElement(name)) + if (!schema.isSimpleElement(qname,parent)) { - String elemType = schema.getElementType(name); + String elemType = schema.getElementType(qname,parent); MetadataType type = schema.getTypeInfo(elemType); @@ -735,7 +853,12 @@ for(int l=0; l<type.getElementCount(); l++) { Element choose = new Element(Edit.ChildElem.Child.CHOOSE, Edit.NAMESPACE); - choose.setAttribute(new Attribute(Edit.Choose.Attr.NAME, type.getElementAt(l))); + String chType = type.getElementAt(l); + //String prefix = getPrefix(chType); + //choose.setAttribute(new Attribute(Edit.Choose.Attr.NAME, getUnqualifiedName(chType))); + choose.setAttribute(new Attribute(Edit.Choose.Attr.NAME, chType)); + //if (!prefix.equals("")) + // choose.setAttribute(new Attribute(Edit.Choose.Attr.PREFIX,prefix)); child.addContent(choose); } @@ -746,9 +869,9 @@ //-------------------------------------------------------------------------- - private void addValues(MetadataSchema schema, Element elem, String name) + private void addValues(MetadataSchema schema, Element elem, String name, String parent) throws Exception { - List values = schema.getElementValues(name); + List values = schema.getElementValues(name,parent); if (values != null) for(int i=0; i<values.size(); i++) { @@ -769,7 +892,12 @@ Element attribute = new Element(Edit.RootChild.ATTRIBUTE, Edit.NAMESPACE); + //String name = getUnqualifiedName(attr.name); + //String prefix = getPrefix(attr.name); + attribute.setAttribute(new Attribute(Edit.Attribute.Attr.NAME, attr.name)); + //if (prefix != null && !prefix.equals("")) + // attribute.setAttribute(new Attribute(Edit.Attribute.Attr.PREFIX, prefix)); //--- add default value (if any) Modified: trunk/src/org/fao/geonet/kernel/schema/AttributeEntry.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/AttributeEntry.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/AttributeEntry.java 2007-07-27 15:51:32 UTC (rev 674) @@ -19,7 +19,7 @@ //=== //=== 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 +//=== 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: geo...@os... @@ -41,7 +41,7 @@ public String defValue; public String reference; public String referenceNS; - public boolean required; + public boolean required = false; public ArrayList alValues = new ArrayList(); @@ -60,6 +60,7 @@ public AttributeEntry(ElementInfo ei) { + Logger.log("Doing attribute"); handleAttribs(ei); handleChildren(ei); } @@ -79,18 +80,26 @@ Attribute at = (Attribute) attribs.get(i); String attrName = at.getName(); + if (attrName.equals("name")) { + name = at.getValue(); + if (ei.targetNSPrefix != null) { + name = ei.targetNSPrefix + ":" + name; + } - if (attrName.equals("name")) - name = (ei.targetNSPrefix == null) ? at.getValue() : ei.targetNSPrefix + ":" + at.getValue(); - + Logger.log("-- name is "+name); + } else if (attrName.equals("default")) defValue = at.getValue(); - else if (attrName.equals("ref")) + else if (attrName.equals("ref")) { reference = at.getValue(); + Logger.log("-- ref is "+reference); + } - else if (attrName.equals("use")) + else if (attrName.equals("use")) { required = "required".equals(at.getValue()); + Logger.log("-- Required is "+required); + } else if (attrName.equals("type")) Logger.log("Skipping 'type' attribute in <attribute> element '"+ name +"'"); @@ -130,3 +139,4 @@ //============================================================================== + Modified: trunk/src/org/fao/geonet/kernel/schema/ComplexContentEntry.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/ComplexContentEntry.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/ComplexContentEntry.java 2007-07-27 15:51:32 UTC (rev 674) @@ -19,7 +19,7 @@ //=== //=== 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 +//=== 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: geo...@os... @@ -32,14 +32,12 @@ import org.jdom.Attribute; import org.jdom.Element; -import jeeves.utils.Xml; //============================================================================== class ComplexContentEntry { public String base; - public ArrayList alElements = new ArrayList(); public ArrayList alAttribs = new ArrayList(); @@ -112,7 +110,9 @@ private void handleExtension(Element el, ElementInfo ei) { base = el.getAttributeValue("base"); + List extension = el.getChildren(); + for(int j=0; j<extension.size(); j++) { Element elExt = (Element) extension.get(j); @@ -125,20 +125,15 @@ { Element elSeq = (Element) sequence.get(k); - if (elSeq.getName().equals("element")) - { - /* RGFIX - String ref = elSeq.getAttributeValue("ref"); - if (ref == null) - throw new IllegalArgumentException("'ref' cannot be null in 'extension' : "+ base); - */ + if (elSeq.getName().equals("element") || elSeq.getName().equals("choice")) alElements.add(new ElementEntry(elSeq, ei.file, ei.targetNS, ei.targetNSPrefix)); - } else Logger.log("Unknown child '"+ elSeq.getName() +"' in <sequence> element", ei); } } + else if (elExt.getName().equals("attribute")) + alAttribs.add(new AttributeEntry(elExt, ei.file, ei.targetNS, ei.targetNSPrefix)); else Logger.log("Unknown child '"+ elExt.getName() +"' in <extension> element ", ei); @@ -150,7 +145,7 @@ private void handleRestriction(Element el, ElementInfo ei) { base = el.getAttributeValue("base"); - + List attribs = el.getAttributes(); for(int i=0; i<attribs.size(); i++) @@ -183,3 +178,4 @@ //============================================================================== + Modified: trunk/src/org/fao/geonet/kernel/schema/ComplexTypeEntry.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/ComplexTypeEntry.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/ComplexTypeEntry.java 2007-07-27 15:51:32 UTC (rev 674) @@ -41,6 +41,7 @@ public String attribGroup; public String groupRef; public boolean isOrType; + public boolean isAbstract; public ComplexContentEntry complexContent; public SimpleContentEntry simpleContent; @@ -86,15 +87,20 @@ Attribute at = (Attribute) attribs.get(i); String attrName = at.getName(); - - if (attrName.equals("name")) - name = (ei.targetNSPrefix == null) ? at.getValue() : ei.targetNSPrefix + ":" + at.getValue(); - + if (attrName.equals("name")) { + name = at.getValue(); + if ((name.indexOf(":") == -1) && (ei.targetNSPrefix != null)) + name = ei.targetNSPrefix + ":" + at.getValue(); + } + else if (attrName.equals("abstract")) { + String abValue = at.getValue(); + isAbstract = abValue.equals("true"); + } else if (attrName.equals("mixed")) Logger.log("Skipping 'mixed' attribute in <complexType> element '"+ name +"'"); - else Logger.log("Unknown attribute '"+ attrName +"' in <complexType> element", ei); + } } @@ -119,7 +125,7 @@ { Element elElem = (Element) sequence.get(j); - if (elElem.getName().equals("element")) + if (elElem.getName().equals("element")) alElements.add(new ElementEntry(elElem, ei.file, ei.targetNS, ei.targetNSPrefix)); else if (elElem.getName().equals("group")) @@ -137,8 +143,9 @@ } else if (elName.equals("attribute")) - alAttribs.add(new AttributeEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix)); // RGFIX + alAttribs.add(new AttributeEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix)); + else if (elName.equals("attributeGroup")) { attribGroup = elChild.getAttributeValue("ref"); @@ -147,12 +154,13 @@ throw new IllegalArgumentException("'ref' is null for <attributeGroup> in complexType : " + name); } - else if (elName.equals("complexContent")) + else if (elName.equals("complexContent")) { + Logger.log("Doing complexContent in <complexType> "+name); complexContent = new ComplexContentEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix); + } else if (elName.equals("simpleContent")) - simpleContent = new SimpleContentEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix); // RGFIX - + simpleContent = new SimpleContentEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix); else if (elName.equals("annotation")) ; @@ -164,3 +172,4 @@ //============================================================================== + Modified: trunk/src/org/fao/geonet/kernel/schema/ElementEntry.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/ElementEntry.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/ElementEntry.java 2007-07-27 15:51:32 UTC (rev 674) @@ -47,13 +47,15 @@ public String substGroupNS; public String ref; public boolean abstrElem; + public boolean choiceElem; + public ArrayList alChoiceElems = new ArrayList(); public ComplexTypeEntry complexType; public SimpleTypeEntry simpleType; //--------------------------------------------------------------------------- //--- - //--- Constructor + //--- Constructor - this class handles both <element> and <choice> entries //--- //--------------------------------------------------------------------------- @@ -70,9 +72,10 @@ public ElementEntry(ElementInfo ei) { - ns = ei.targetNS; + ns = ei.targetNS; handleAttribs(ei); - handleChildren(ei); + if (choiceElem) handleChoiceChildren(ei); + else handleChildren(ei); } //--------------------------------------------------------------------------- @@ -86,7 +89,7 @@ ElementEntry ee = new ElementEntry(); ee.name = name; - ee.ns = ns; + ee.ns = ns; ee.type = type; ee.min = min; ee.max = max; @@ -97,6 +100,8 @@ ee.complexType = complexType; ee.simpleType = simpleType; + ee.choiceElem = choiceElem; + ee.alChoiceElems = alChoiceElems; return ee; } @@ -109,41 +114,53 @@ private void handleAttribs(ElementInfo ei) { + if (ei.element.getName().equals("choice")) choiceElem = true; + List attrs = ei.element.getAttributes(); for(int i=0; i<attrs.size(); i++) { - Attribute attr = (Attribute) attrs.get(i); + Attribute at = (Attribute) attrs.get(i); - String name = attr.getName(); - String value= attr.getValue(); + String attrName = at.getName(); + String value= at.getValue(); - if (name.equals("name")) - this.name = (ei.targetNSPrefix == null) ? value : ei.targetNSPrefix + ":" + value; - - else if (name.equals("type")) + if (attrName.equals("name")) { + name = at.getValue(); + if ((name.indexOf(":") == -1) && (ei.targetNSPrefix != null)) + name = ei.targetNSPrefix + ":" + at.getValue(); + Logger.log("Doing Element "+name); + } + else if (attrName.equals("type")) + { type = value; + Logger.log("element "+this.name+" has type "+type); + } - else if (name.equals("ref")) + else if (attrName.equals("ref")) ref = value; - else if (name.equals("substitutionGroup")) + else if (attrName.equals("substitutionGroup")) substGroup = value; - else if (name.equals("abstract")) + else if (attrName.equals("abstract")) { abstrElem = "true".equals(value); - - else if (name.equals("minOccurs")) + Logger.log(" -- is abstract"); + } + else if (attrName.equals("minOccurs")) min = Integer.parseInt(value); - else if (name.equals("maxOccurs")) + else if (attrName.equals("maxOccurs")) { if (value.equals("unbounded")) max = 10000; else max = Integer.parseInt(value); } - else - Logger.log("Unknown attribute '" +attr.getName()+ "'in <element> element", ei); + else { + if (choiceElem) Logger.log("Unknown attribute '" +attrName+ "'in <choice> element", ei); + else Logger.log("Unknown attribute '" +attrName+ "'in <element> element", ei); + + } } } @@ -161,20 +178,64 @@ if (elName.equals("complexType")) complexType = new ComplexTypeEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix); - else if (elName.equals("simpleType")) - { + else if (elName.equals("simpleType")) { simpleType = new SimpleTypeEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix); + if (simpleType.name == null) simpleType.name = name+"#S"; } + else if (elName.equals("key")) Logger.log("Skipping 'key' child in <element> element '"+ name +"'"); else if (elName.equals("annotation")) - ; + ; else Logger.log("Unknown child '" +elName+ "' in <element> element", ei); } } + + //--------------------------------------------------------------------------- + + private void handleChoiceChildren(ElementInfo ei) + { + List children = ei.element.getChildren(); + + for(int i=0; i<children.size(); i++) + { + Element elChild = (Element) children.get(i); + String elName = elChild.getName(); + + if (elName.equals("annotation")) { + List appinfo = elChild.getChildren(); + for (int j=0;i < appinfo.size(); j++) { + Element elElem = (Element) appinfo.get(j); + if (elElem.getName().equals("appinfo")) { + name = (String) elElem.getText(); + } + } + } + + else if (elName.equals("element") || elName.equals("choice")) { + ArrayList alElems = new ArrayList(); + alChoiceElems.add(alElems); + alElems.add(new ElementEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix)); + } + else if (elName.equals("sequence")) { + ArrayList alElems = new ArrayList(); + alChoiceElems.add(alElems); + List sequence = elChild.getChildren(); + for (int j=0;i < sequence.size(); j++) { + Element elSeq = (Element) sequence.get(j); + + if (elName.equals("element") || elName.equals("choice")) + alElems.add(new ElementEntry(elChild, ei.file, ei.targetNS, ei.targetNSPrefix)); + } + } + + else + Logger.log("Unknown child '" +elName+ "' in <choice> element", ei); + } + } } //============================================================================== Modified: trunk/src/org/fao/geonet/kernel/schema/GroupEntry.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/GroupEntry.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/GroupEntry.java 2007-07-27 15:51:32 UTC (rev 674) @@ -68,11 +68,12 @@ { Attribute at = (Attribute) attribs.get(i); - String attrName = at.getName(); - - if (attrName.equals("name")) - name = (ei.targetNSPrefix == null) ? at.getValue() : ei.targetNSPrefix + ":" + at.getValue(); - + String attrName = at.getName(); + if (attrName.equals("name")) { + name = at.getValue(); + if ((name.indexOf(":") == -1) && (ei.targetNSPrefix != null)) + name = ei.targetNSPrefix + ":" + at.getValue(); + } else Logger.log("Unknown attribute '"+ attrName +"' in <group> element", ei); } Modified: trunk/src/org/fao/geonet/kernel/schema/Logger.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/Logger.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/Logger.java 2007-07-27 15:51:32 UTC (rev 674) @@ -48,8 +48,8 @@ public static void log(String message) { -// System.out.println(message); - logSeparator(); + // System.out.println(message); + // logSeparator(); } //--------------------------------------------------------------------------- @@ -58,10 +58,10 @@ { String file = new File(ei.file).getName(); -// System.out.println(message); -// System.out.println("File is : " + file); -// System.out.println("Element is : \n" + Xml.getString(ei.element)); - logSeparator(); + // System.out.println(message); + // System.out.println("File is : " + file); + // System.out.println("Element is : \n" + Xml.getString(ei.element)); + // logSeparator(); } //--------------------------------------------------------------------------- @@ -72,7 +72,7 @@ private static void logSeparator() { -// System.out.println("---------------------------------------------------------"); + // System.out.println("---------------------------------------------------------"); } } Modified: trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java 2007-07-27 15:51:32 UTC (rev 674) @@ -35,9 +35,11 @@ public class MetadataSchema { - private HashMap hmElements = new HashMap(); - private HashMap hmRestric = new HashMap(); + private Map<String,List<String>> hmElements = new HashMap<String,List<String>>(); + private Map<String,List<List>> hmRestric = new HashMap<String,List<List>>(); private HashMap hmTypes = new HashMap(); + private HashMap hmSubs = new HashMap(); + private HashMap hmSubsLink = new HashMap(); //--------------------------------------------------------------------------- //--- @@ -55,16 +57,58 @@ public MetadataType getTypeInfo(String type) { - return (MetadataType) hmTypes.get(type); + Logger.log("metadataSchema: Asking for type "+type); + if (hmTypes.get(type) == null) return new MetadataType(); + else return (MetadataType) hmTypes.get(type); } //--------------------------------------------------------------------------- - public String getElementType(String elem) + public String getElementType(String elem,String parent) throws Exception { - //System.out.println("in getElementType(" + elem + ")"); // DEBUG + // two cases here - if we have just one element (or a substitute) with + // this name then return its type - return (String) hmElements.get(elem); + Logger.log("metadataSchema: Asking for element "+elem+" parent "+parent); + List<String> childType = hmElements.get(elem); + if (childType == null) { + // Check and see whether we can substitute another element from the + // list of substitution links - just process the arrayList until + // we find one that matches + ArrayList alSubsLink = (ArrayList) hmSubsLink.get(elem); + Logger.log("metadataSchema: checking subs for element "+elem+" parent "+parent); + if (alSubsLink != null) { + for (int i = 0;i< alSubsLink.size();i++) { + elem = (String) alSubsLink.get(i); + Logger.log(" -- substitute "+elem); + childType = hmElements.get(elem); + if (childType != null) continue; + } + } + if (childType == null) + throw new IllegalArgumentException("Mismatch between schema and xml: No type for 'element' : "+elem+" with parent "+parent); + } + if (childType.size() == 1) return childType.get(0); + + Logger.log("-- Multiple elements so moving to parent"); + // OTHERWISE get the type by examining the parent: + // for each parent with that name parent + // 1. retrieve its mdt + List<String> exType = hmElements.get(parent); + Iterator i = exType.iterator(); + while (i.hasNext()) { + // 2. search that mdt for the element names elem + String type = (String)i.next(); + MetadataType mdt = getTypeInfo(type); + for (int k = 0;k < mdt.getElementCount();k++) { + String elemTest = mdt.getElementAt(k); + // 3. return the type name of that element + if (elem.equals(elemTest)) return mdt.getElementTypeAt(k); + } + } + + Logger.log("ERROR: could not find type for element "+elem+" with parent "+parent); + return null; } //--------------------------------------------------------------------------- @@ -72,127 +116,94 @@ * have restrictions on its value) */ - public boolean isSimpleElement(String elem) + public boolean isSimpleElement(String elem,String parent) throws Exception { - //System.out.println("in isSimpleElement(" + elem + ")"); // DEBUG - - return !hmTypes.containsKey(getElementType(elem)); + String type = getElementType(elem,parent); + if (type == null) return false; + else return !hmTypes.containsKey(type); } //--------------------------------------------------------------------------- - public ArrayList getElementValues(String elem) + public ArrayList getElementSubs(String elem) { - return (ArrayList) hmRestric.get(elem); + return((ArrayList)hmSubs.get(elem)); } //--------------------------------------------------------------------------- - //--- - //--- Package protected API methods - //--- - //--------------------------------------------------------------------------- - void addElement(String name, String type, ArrayList values) + public ArrayList getElementValues(String elem,String parent) throws Exception { - //System.out.println("#### adding element " + name); // DEBUG - hmElements.put(name, type); - hmRestric .put(name, values); - } + String type = getElementType(elem,parent); + String restricName = elem; + if (type != null) restricName = restricName+"+"+type; - //--------------------------------------------------------------------------- + // two cases here - if we have just one element with this name + // then return its values + List<List> childValues = hmRestric.get(restricName); + if (childValues == null) return null; + if (childValues.size() == 1) return (ArrayList)childValues.get(0); - void addType(String name, MetadataType mdt) - { - //System.out.println("#### adding type " + name); // DEBUG - - mdt.setName(name); - hmTypes.put(name, mdt); + // OTHERWISE we don't know what to do so return the first one anyway! This + // should not happen.... + Logger.log("WARNING: returning first set of values for element "+elem+" this should not happen and it may not be correct.....check logs for VALUESCLASH statements and fix schema"); + return (ArrayList)childValues.get(0); } //--------------------------------------------------------------------------- //--- - //--- Debug methods + //--- Package protected API methods //--- //--------------------------------------------------------------------------- - public String dump(String type) + void addElement(String name, String type, ArrayList alValues, ArrayList alSubs, ArrayList alSubsLink) { - return dump(type, new HashSet()); - } + // first just add the subs - because these are for global elements we + // never have a clash because global elements are all in the same scope + // and are thus unique + if (alSubs != null && alSubs.size() > 0) hmSubs.put(name,alSubs); + if (alSubsLink != null && alSubsLink.size() > 0) hmSubsLink.put(name,alSubsLink); - //--------------------------------------------------------------------------- + List<String> exType = hmElements.get(name); - private String dump(String type, HashSet hs) - { - StringBuffer sb = new StringBuffer(""); + // it's already there but the type has been added already + if (exType != null && exType.contains(type)) return; - MetadataType mdt = getTypeInfo(type); + // it's already there but doesn't have this type + if (exType != null && !(exType.contains(type))) { + Logger.log("CLASH: trying to add "+name+" with type "+type+": already exists with type: "+exType+" - adding overflows and code to cope"); - if (mdt == null) - throw new IllegalArgumentException("Unknown type : " + type); - hs.add(type); - - sb.append(type); - sb.append(" ("); - - String sep = mdt.isOrType() ? " | " : ", "; - - for(int i=0; i<mdt.getElementCount(); i++) - { - String elem = mdt.getElementAt(i); - - int min = mdt.getMinCardinAt(i); - int max = mdt.getMaxCardinAt(i); - - sb.append(elem); - - if (min == 0) - { - if (max == 1) sb.append("?"); - else sb.append("*"); - } - else - { - if (max == 1) sb.append(""); - else sb.append("+"); - } - - if (i < mdt.getElementCount() -1) - sb.append(sep); + // it's not there so add a new list + } else { + hmElements.put(name, exType = new ArrayList<String>()); } + exType.add(type); - sb.append(")\n\n"); + String restricName = name; + if (type != null) restricName = name+"+"+type; - ArrayList al = new ArrayList(); + // it's already there + List<List> exValues = hmRestric.get(restricName); + if (exValues != null) { + Logger.log("VALUESCLASH: trying to add "+restricName+" with values "+alValues+": already exists with values "+exValues+" - this should not happen"); - for(int i=0; i<mdt.getElementCount(); i++) - { - String elem = mdt.getElementAt(i); - type = getElementType(elem); - - if (type == null) - throw new IllegalArgumentException("Unknown type for elem : " + elem); - - sb.append(elem +" : "+type+"\n"); - - if (!isSimpleElement(type)) - al.add(type); + // it's not there so add a new list of lists + } else { + hmRestric .put(restricName, exValues = new ArrayList<List>()); } + exValues.add(alValues); + } - sb.append("\n"); + //--------------------------------------------------------------------------- - for(int i=0; i<al.size(); i++) - { - type = (String) al.get(i); + void addType(String name, MetadataType mdt) + { + mdt.setName(name); + hmTypes.put(name, mdt); + } - if (!hs.contains(type)) - sb.append(dump(type, hs)); - } - - return sb.toString(); - } } //============================================================================== Modified: trunk/src/org/fao/geonet/kernel/schema/MetadataType.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/MetadataType.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/MetadataType.java 2007-07-27 15:51:32 UTC (rev 674) @@ -28,7 +28,11 @@ package org.fao.geonet.kernel.schema; import java.util.ArrayList; +import java.util.List; +import org.jdom.Attribute; +import org.jdom.Element; + //============================================================================== public class MetadataType @@ -36,10 +40,12 @@ private String name; private boolean isOrType; - private ArrayList alElements = new ArrayList(); - private ArrayList alMinCard = new ArrayList(); - private ArrayList alMaxCard = new ArrayList(); - private ArrayList alAttribs = new ArrayList(); + private ArrayList alElements = new ArrayList(); + private ArrayList alTypes = new ArrayList(); + private ArrayList alMinCard = new ArrayList(); + private ArrayList alMaxCard = new ArrayList(); + private ArrayList alAttribs = new ArrayList(); + private ArrayList alExamineSubs = new ArrayList(); //--------------------------------------------------------------------------- //--- @@ -57,6 +63,11 @@ public int getElementCount() { return alElements.size(); } + public void resetElementAt(int pos,String name,String type) { + alElements.set(pos,name); + alTypes.set(pos,type); + } + //-------------------------------------------------------------------------- /** Return the component in a given position */ @@ -66,6 +77,23 @@ } //-------------------------------------------------------------------------- + /** Return the type of element in a given position */ + + public String getElementTypeAt(int pos) + { + return (String) alTypes.get(pos); + } + + //-------------------------------------------------------------------------- + /** Return true if subs for element in given position need to be examined, + * false otherwise */ + + public Boolean examineSubs(int pos) + { + return (Boolean) alExamineSubs.get(pos); + } + + //-------------------------------------------------------------------------- /** Returns the min cardinality of element in a given pos */ public int getMinCardinAt(int pos) @@ -107,6 +135,9 @@ { String res = ""; + if (isOrType) res += "IsOrType = TRUE "; + else res += "IsOrType = FALSE "; + for(int i=0; i<alElements.size(); i++) { String comp = getElementAt(i); @@ -119,6 +150,22 @@ res += comp + "/" + min+ "-" + sMax + " "; } + + String attrs = ""; + for(int i=0; i<alAttribs.size(); i++) + { + attrs += "Attribute ("+i+") "+getAttributeAt(i).name+": "; + ArrayList alAtts = getAttributeAt(i).values; + if (alAtts.size() > 0) { + attrs += getAttributeAt(i).values.toString(); + attrs += " "; + } + attrs += "Default Value: "+getAttributeAt(i).defValue; + if (getAttributeAt(i).required) attrs += " REQUIRED "; + } + if (attrs.length() > 0) + res += " Attributes: "+attrs; + return res; } @@ -128,10 +175,39 @@ //--- //--------------------------------------------------------------------------- - void addElement(String name, int minCard, int maxCard) + void addElementWithType(String name, String elementType, int minCard, int maxCard) { + addElement(name,elementType,false,minCard,maxCard); + } + + //--------------------------------------------------------------------------- + + void addElementWithNoType(String name, int minCard, int maxCard) + { + addElement(name,null,false,minCard,maxCard); + } + + //--------------------------------------------------------------------------- + + void addRefElementWithType(String name, String elementType, int minCard, int maxCard) + { + addElement(name,elementType,true,minCard,maxCard); + } + + //--------------------------------------------------------------------------- + + void addRefElementWithNoType(String name, int minCard, int maxCard) + { + addElement(name,null,true,minCard,maxCard); + } + + //--------------------------------------------------------------------------- + + void addElement(String name, String elementType, Boolean examineElementSubs, int minCard, int maxCard) + { alElements.add(name); - + alTypes.add(elementType); + alExamineSubs.add(examineElementSubs); alMinCard.add(new Integer(minCard)); alMaxCard.add(new Integer(maxCard)); } Modified: trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java 2007-07-27 14:29:28 UTC (rev 673) +++ trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java 2007-07-27 15:51:32 UTC (rev 674) @@ -44,6 +44,7 @@ private HashMap hmAbsElems = new HashMap(); private HashMap hmSubsGrp = new HashMap(); private HashMap hmSubsLink = new HashMap(); + private HashMap hmSubsNames = new HashMap(); private HashMap hmAttribs = new HashMap(); private HashMap hmGroups = new HashMap(); @@ -90,6 +91,8 @@ String elem = (String) i.next(); ArrayList elements = (ArrayList) hmSubsGrp.get(elem); + ArrayList subsNames = new ArrayList(); + hmSubsNames.put(elem,subsNames); for(int j=0; j<elements.size(); j++) { ElementEntry ee = (ElementEntry) elements.get(j); @@ -102,6 +105,7 @@ } hmElements.put(ee.name, ee.type); + subsNames.add(ee.name); } } @@ -122,7 +126,11 @@ if (typeRestr != null) elemRestr.addAll(typeRestr); - mds.addElement(elem, type, elemRestr); + ArrayList elemSubs = (ArrayList) hmSubsNames.get(elem); + if (elemSubs == null) elemSubs = new ArrayList(); + ArrayList elemSubsLink = (ArrayList) hmSubsLink.get(elem); + if (elemSubsLink == null) elemSubsLink = new ArrayList(); + mds.addElement(elem, type, elemRestr, elemSubs, elemSubsLink); } //--- PHASE 4 : post-processing @@ -133,7 +141,7 @@ for(Iterator i=hmTypes.values().iterator(); i.hasNext();) { ComplexTypeEntry cte = (ComplexTypeEntry) i.next(); - + Logger.log("Doing complexType "+cte.name); MetadataType mdt = new MetadataType(); mdt.setOrType(cte.isOrType); @@ -165,17 +173,21 @@ if (cte.complexContent != null) { - if (cte.complexContent.base != null) + + if (cte.complexContent.base != null) { cte.alElements = resolveInheritance(cte); + ArrayList complexContentAttribs = resolveAttributeInheritance(cte); - //--- add attribs from complexContent (if any) + //--- add attribs from complexContent (if any) - this needs + //--- to be recursive because we might have some - for(int j=0; j<cte.complexContent.alAttribs.size(); j++) - { - AttributeEntry ae = (AttributeEntry) cte.complexContent.alAttribs.get(j); + Logger.log("Attributes resolved: "+complexContentAttribs.size()); + for(int j=0; j<complexContentAttribs.size(); j++) { + AttributeEntry ae = (AttributeEntry) complexContentAttribs.get(j); + mdt.addAttribute(buildMetadataAttrib(ae)); + } + } - mdt.addAttribute(buildMetadataAttrib(ae)); - } } //--- resolve inheritance & add attribs from simpleContent @@ -202,12 +214,13 @@ if (ge.isChoice) { - ElementEntry ee = (ElementEntry) ge.alElements.get(0); - ElementEntry eeRef = (ElementEntry) hmElements.get(ee.ref); + ElementEntry ee = (ElementEntry) ge.alElements.get(0); + String eeRefType = (String) hmElements.get(ee.ref); - //--- if the ref was not found then we have an abstract element + //--- if the ref type was not found and the element was in + //--- the abstract elements hm then we have an abstract element - if (eeRef == null) + if (eeRefType == null || hmAbsElems.containsKey(ee.ref)) { ArrayList al = (ArrayList) hmSubsGrp.get(ee.ref); @@ -218,11 +231,11 @@ { ElementEntry eeDer = (ElementEntry) al.get(k); - mdt.addElement(eeDer.name, ee.min, ee.max); + mdt.addElementWithType(eeDer.name, cte.name, ee.min, ee.max); } } else - throw new IllegalArgumentException("Found not abstract element in choice : " +eeRef.name); + throw new IllegalArgumentException("Found an element which is not abstract in choice type : " +ee.ref); } } @@ -232,63 +245,95 @@ { ElementEntry ee = (ElementEntry) cte.alElements.get(j); - //System.out.println("resolving element " + (ee.name == null ? (" --> " + ee.ref) : ee.name)); // DEBUG + Logger.log("resolving element " + (ee.name == null ? (" --> " + ee.ref) : ee.name)); // DEBUG String type; + Boolean abstrElement = false; + +// Three situations: +// 1. element is a reference to a global element so check if abstract if (ee.ref != null) { type = (String) hmElements.get(ee.ref); + if (hmAbsElems.containsKey(ee.ref)) abstrElement = true; - //System.out.println("- type = " + type); // DEBUG + Logger.log("- ee.ref = "+ee.ref+" type = " + type + " abstract = "+abstrElement); // DEBUG } - else +// 2. element is a local element so get type + else if (ee.name != null) { - if (ee.name == null) - throw new IllegalArgumentException("Reference and name are null for element : " + ee.name); - - // RGFIX type = "string"; type = ee.type == null ? "string" : ee.type; + + Logger.log("- type = " + type); // DEBUG - //System.out.println("- type = " + type); // DEBUG + mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), new ArrayList()); - mds.addElement(ee.name, type, new ArrayList()); +// 3. element is a choice element or an error + } else { + if (!ee.choiceElem) + throw new IllegalArgumentException("Reference and name are null for element at position "+j+" in complexType "+cte.name); + + // Create a base name derived from cte.name and element position + // because choice elements are anonymous - add CHOICEELEMENT and + // an identifier to make it unique + + Integer baseChoiceNr = j; + String baseChoiceName = cte.name+"CHOICE_ELEMENT"; + type = ee.name = baseChoiceName+baseChoiceNr; + + // Traverse the list of elements in the choice element and + // create an mdt with the chosen name and process any nested choices + createTypeAndResolveNestedChoices(mds,ee.alChoiceElems, + baseChoiceName,baseChoiceNr); + mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), new ArrayList()); + } - //--- if type is null we have an abstract type + //--- if type is null or the element is a ref to an + //--- abstract element then we have an abstract type to + //--- process - if (type == null) + if (type == null || abstrElement) { ArrayList al = (ArrayList) hmSubsGrp.get(ee.ref); if (al == null) { al = (ArrayList) hmSubsLink.get(ee.ref); - /* RGFIX: found singleton subst-group with only one abstract element - if (al == null) - throw new IllegalArgume... [truncated message content] |
From: <aca...@us...> - 2007-07-28 14:04:18
|
Revision: 680 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=680&view=rev Author: acarboni Date: 2007-07-28 07:04:18 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Commented out unfinished harvesting modules Modified Paths: -------------- trunk/docs/changes.txt trunk/web/geonetwork/scripts/harvesting/harvesting.js Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-07-28 13:26:59 UTC (rev 679) +++ trunk/docs/changes.txt 2007-07-28 14:04:18 UTC (rev 680) @@ -54,6 +54,11 @@ - Fixed bug with data upload: if the browser was IE and the server was running on linux the upload file name contained the file path +- Fixed a bug in user creation page: it was not possible to create administrators + +- Fixed a nasty bug in the editor that caused a stack overflow with date + and thesaurusName elements. + ================================================================================ === === GeoNetwork 2.1.0 beta4 : List of changes Modified: trunk/web/geonetwork/scripts/harvesting/harvesting.js =================================================================== --- trunk/web/geonetwork/scripts/harvesting/harvesting.js 2007-07-28 13:26:59 UTC (rev 679) +++ trunk/web/geonetwork/scripts/harvesting/harvesting.js 2007-07-28 14:04:18 UTC (rev 680) @@ -74,10 +74,10 @@ function init() { view.register(geonet); - view.register(webdav); +// view.register(webdav); view.register(csw); view.register(geonet20); - view.register(z3950); +// view.register(z3950); view.show(SHOW.LIST); refresh(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-06 13:21:57
|
Revision: 699 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=699&view=rev Author: acarboni Date: 2007-08-06 06:21:58 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Added 'transfer ownership' capability Modified Paths: -------------- trunk/src/org/fao/geonet/constants/Geonet.java trunk/src/org/fao/geonet/services/ownership/Groups.java trunk/web/geonetwork/WEB-INF/config-metadata.xml trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml trunk/web/geonetwork/scripts/ownership/model.js trunk/web/geonetwork/scripts/ownership/transfer-ownership.js trunk/web/geonetwork/scripts/ownership/view.js trunk/web/geonetwork/xsl/config/config.xsl trunk/web/geonetwork/xsl/ownership/client-group-row.xsl trunk/web/geonetwork/xsl/ownership/transfer-ownership.xsl Added Paths: ----------- trunk/src/org/fao/geonet/services/ownership/Transfer.java Modified: trunk/src/org/fao/geonet/constants/Geonet.java =================================================================== --- trunk/src/org/fao/geonet/constants/Geonet.java 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/src/org/fao/geonet/constants/Geonet.java 2007-08-06 13:21:58 UTC (rev 699) @@ -223,6 +223,7 @@ public static final String INDEX_ENGINE = GEONETWORK + ".index"; public static final String MEF = GEONETWORK + ".mef"; public static final String CSW = GEONETWORK + ".csw"; + public static final String LDAP = GEONETWORK + ".ldap"; public static final String CSW_SEARCH = CSW + ".search"; Modified: trunk/src/org/fao/geonet/services/ownership/Groups.java =================================================================== --- trunk/src/org/fao/geonet/services/ownership/Groups.java 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/src/org/fao/geonet/services/ownership/Groups.java 2007-08-06 13:21:58 UTC (rev 699) @@ -72,8 +72,11 @@ for (String groupId : userGroups) { - String query = "SELECT count(*) as cnt FROM OperationAllowed WHERE groupId=?"; - List list = dbms.select(query, new Integer(groupId)).getChildren(); + String query = "SELECT count(*) as cnt "+ + "FROM OperationAllowed, Metadata "+ + "WHERE metadataId = id AND groupId=? AND owner=?"; + + List list = dbms.select(query, new Integer(groupId), id).getChildren(); String size = ((Element)list.get(0)).getChildText("cnt"); if (Integer.parseInt(size) != 0) Added: trunk/src/org/fao/geonet/services/ownership/Transfer.java =================================================================== --- trunk/src/org/fao/geonet/services/ownership/Transfer.java (rev 0) +++ trunk/src/org/fao/geonet/services/ownership/Transfer.java 2007-08-06 13:21:58 UTC (rev 699) @@ -0,0 +1,137 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.services.ownership; + +import java.sql.SQLException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; +import jeeves.interfaces.Service; +import jeeves.resources.dbms.Dbms; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Util; +import org.fao.geonet.GeonetContext; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.DataManager; +import org.jdom.Element; + +//============================================================================= + +public class Transfer implements Service +{ + public void init(String appPath, ServiceConfig params) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + public Element exec(Element params, ServiceContext context) throws Exception + { + int sourceUsr = Util.getParamAsInt(params, "sourceUser"); + int sourceGrp = Util.getParamAsInt(params, "sourceGroup"); + int targetUsr = Util.getParamAsInt(params, "targetUser"); + int targetGrp = Util.getParamAsInt(params, "targetGroup"); + + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + DataManager dm = gc.getDataManager(); + + Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); + + //--- transfer privileges (if case) + + Set<String> sourcePriv = retrievePrivileges(dbms, sourceUsr, sourceGrp); + Set<String> targetPriv = retrievePrivileges(dbms, targetUsr, targetGrp); + + //--- a commit just to release some resources + + dbms.commit(); + + int privCount = 0; + + Set<Integer> metadata = new HashSet<Integer>(); + + for (String priv : sourcePriv) + { + StringTokenizer st = new StringTokenizer(priv, "|"); + + int opId = Integer.parseInt(st.nextToken()); + int mdId = Integer.parseInt(st.nextToken()); + + dm.unsetOperation(dbms, mdId, sourceGrp, opId); + + if (!targetPriv.contains(priv)) + dbms.execute("INSERT INTO OperationAllowed(metadataId, groupId, operationId) " + + "VALUES(?,?,?)", mdId, targetGrp, opId); + + dbms.execute("UPDATE Metadata SET owner=? WHERE id=?", targetUsr, mdId); + + metadata.add(mdId); + privCount++; + } + + dbms.commit(); + + //--- reindex metadata + + for (int mdId : metadata) + dm.indexMetadata(dbms, Integer.toString(mdId)); + + //--- return summary + + return new Element("response") + .addContent(new Element("privileges").setText(privCount +"")) + .addContent(new Element("metadata") .setText(metadata.size()+"")); + } + + //-------------------------------------------------------------------------- + + private Set<String> retrievePrivileges(Dbms dbms, int userId, int groupId) throws SQLException + { + String query = "SELECT * "+ + "FROM OperationAllowed, Metadata "+ + "WHERE metadataId=id AND owner=? AND groupId=?"; + + List list = dbms.select(query, userId, groupId).getChildren(); + + Set<String> result = new HashSet<String>(); + + for (Object o : list) + { + Element elem = (Element) o; + String opId = elem.getChildText("operationid"); + String mdId = elem.getChildText("metadataid"); + + result.add(opId +"|"+ mdId); + } + + return result; + } +} + +//============================================================================= + Modified: trunk/web/geonetwork/WEB-INF/config-metadata.xml =================================================================== --- trunk/web/geonetwork/WEB-INF/config-metadata.xml 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/WEB-INF/config-metadata.xml 2007-08-06 13:21:58 UTC (rev 699) @@ -31,22 +31,22 @@ </service> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - + <service name="metadata.show.embedded"> <class name=".services.metadata.Show"/> - + <output sheet="metadata-show-embedded.xsl"> <call name="services" class="jeeves.guiservices.services.Get"/> <call name="currTab" class=".guiservices.util.GetCurrentMDTab"/> <call name="sources" class=".guiservices.util.Sources"/> <call name="isoLang" class=".guiservices.isolanguages.Get"/> </output> - + <error id="operation-not-allowed" sheet="error.xsl"> <xml name="privError" file="xml/privileges-error.xml" /> </error> </service> - + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="metadata.edit"> @@ -317,6 +317,12 @@ <service name="xml.ownership.groups"> <class name=".services.ownership.Groups"/> </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + <service name="xml.ownership.transfer"> + <class name=".services.ownership.Transfer"/> + </service> </services> </geonet> Modified: trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml =================================================================== --- trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml 2007-08-06 13:21:58 UTC (rev 699) @@ -8,6 +8,9 @@ <operation>Operation</operation> <cannotRetrieve>Cannot retrieve information from server</cannotRetrieve> + <cannotTransfer>Cannot transfer ownership</cannotTransfer> + <noUser>No target user to transfer ownership to</noUser> <transfer>Transfer</transfer> + <result>Transferred {PRIV} privileges of {MD} metadata</result> </strings> Modified: trunk/web/geonetwork/scripts/ownership/model.js =================================================================== --- trunk/web/geonetwork/scripts/ownership/model.js 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/scripts/ownership/model.js 2007-08-06 13:21:58 UTC (rev 699) @@ -13,6 +13,7 @@ this.getUsers = getUsers; this.getUserGroups = getUserGroups; + this.transfer = transfer; //===================================================================================== //=== @@ -47,11 +48,43 @@ } //===================================================================================== -//=== -//=== Private methods -//=== + +function transfer(sourceUsr, sourceGrp, targetUsr, targetGrp, callBack) +{ + callBackF = callBack; + + var data = + { + SOURCE_USR : sourceUsr, + SOURCE_GRP : sourceGrp, + TARGET_USR : targetUsr, + TARGET_GRP : targetGrp + }; + + var request = str.substitute(transferTemp, data); + + ker.send('xml.ownership.transfer', request, ker.wrap(this, transfer_OK)); +} + +//------------------------------------------------------------------------------------- + +function transfer_OK(xmlRes) +{ + if (xmlRes.nodeName == 'error') + ker.showError(loader.getText('cannotTransfer'), xmlRes); + else + callBackF(xmlRes); +} + //===================================================================================== +var transferTemp = +'<request>'+ +' <sourceUser>{SOURCE_USR}</sourceUser>'+ +' <sourceGroup>{SOURCE_GRP}</sourceGroup>'+ +' <targetUser>{TARGET_USR}</targetUser>'+ +' <targetGroup>{TARGET_GRP}</targetGroup>'+ +'</request>'; //===================================================================================== } Modified: trunk/web/geonetwork/scripts/ownership/transfer-ownership.js =================================================================== --- trunk/web/geonetwork/scripts/ownership/transfer-ownership.js 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/scripts/ownership/transfer-ownership.js 2007-08-06 13:21:58 UTC (rev 699) @@ -31,7 +31,8 @@ //--- public methods - this.init = init; + this.init = init; + this.transfer = transfer; //===================================================================================== //=== @@ -56,6 +57,39 @@ //===================================================================================== +function transfer(groupId) +{ + var tr = $(groupId); + + var sourceGrp = tr.getAttribute('id'); + var sourceUsr = $F('source.user'); + var targetGrp = $F(xml.getElementById(tr, 'target.group')); + var targetUsr = $F(xml.getElementById(tr, 'target.user')); + + if (targetUsr == null) + alert(loader.getText('noUser')); + else + model.transfer(sourceUsr, sourceGrp, targetUsr, targetGrp, ker.wrap(this, function(xmlRes) + { + var data = + { + PRIV : xml.evalXPath(xmlRes, 'privileges'), + MD : xml.evalXPath(xmlRes, 'metadata') + }; + + var msg = str.substitute(loader.getText('result'), data); + + alert(msg); + + if (sourceGrp != targetGrp) + Element.remove(tr); + })); +} + +//===================================================================================== +//=== Listener +//===================================================================================== + function sourceUserChange(event) { view.clearGroupList(); @@ -63,7 +97,7 @@ var userId = $F('source.user'); if (userId != '') - model.getUserGroups(userId, ker.wrap(view, view.addGroupRows)); + model.getUserGroups(userId, ker.wrap(view, view.addGroupRows)); } //===================================================================================== Modified: trunk/web/geonetwork/scripts/ownership/view.js =================================================================== --- trunk/web/geonetwork/scripts/ownership/view.js 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/scripts/ownership/view.js 2007-08-06 13:21:58 UTC (rev 699) @@ -9,7 +9,8 @@ var rowTransf = new XSLTransformer('ownership/client-group-row.xsl', xmlLoader); var loader = xmlLoader; - + var cache = null; + this.addSourceUser = addSourceUser; this.clearGroupList= clearGroupList; this.addGroupRows = addGroupRows; @@ -22,8 +23,7 @@ function addSourceUser(id, name) { - var html='<option value="'+ id +'">'+ xml.escape(name) +'</option>'; - new Insertion.Bottom('source.user', html); + gui.addToSelect('source.user', id, name); } //===================================================================================== @@ -38,18 +38,93 @@ function addGroupRows(groupList) { + cache = groupList; + var list = xml.children(groupList, 'group'); + //--- add group rows + for (var i=0; i<list.length; i++) { + var id = xml.evalXPath(list[i], 'id'); var xslRes = rowTransf.transform(list[i]); //--- add the new search in list - new Insertion.Bottom('group.list', xml.toString(xslRes)); + gui.appendTableRow('group.list', xslRes) + + var tr = $(id); + + var targetGrp = xml.getElementById(tr, 'target.group'); + var targetUsr = xml.getElementById(tr, 'target.user'); + + Event.observe(targetGrp, 'change', ker.wrap(this, targetChange)); + + addTargetGroups(id, targetGrp); + setTargetUsers (id, targetUsr); + + targetGrp.targetUsr = targetUsr; } Element.show('groups'); } +//===================================================================================== +function addTargetGroups(groupId, ctrl) +{ + var list = xml.children(cache, 'targetGroup'); + + for (var i=0; i<list.length; i++) + { + var tarId = xml.evalXPath(list[i], 'id'); + var tarName = xml.evalXPath(list[i], 'label/'+Env.lang); + + gui.addToSelect(ctrl, tarId, tarName, groupId == tarId); + } +} + //===================================================================================== + +function setTargetUsers(groupId, ctrl) +{ + var srcId = $F('source.user'); + + //--- remove all users + $(ctrl).options.length = 0; + + var list = xml.children(cache, 'targetGroup'); + + for (var i=0; i<list.length; i++) + { + var tarId = xml.evalXPath(list[i], 'id'); + + if (tarId == groupId) + { + var editors = xml.children(list[i], 'editor'); + + for (var j=0; j<editors.length; j++) + { + var edId = xml.evalXPath(editors[j], 'id'); + var name = xml.evalXPath(editors[j], 'name'); + var surn = xml.evalXPath(editors[j], 'surname'); + + if (edId != srcId) + gui.addToSelect(ctrl, edId, surn +' '+ name); + } + } + } } + +//===================================================================================== +//=== Listener +//===================================================================================== + +function targetChange(e) +{ + var ctrl = Event.element(e); + var id = $F(ctrl); + + setTargetUsers(id, ctrl.targetUsr); +} + +//===================================================================================== +} Modified: trunk/web/geonetwork/xsl/config/config.xsl =================================================================== --- trunk/web/geonetwork/xsl/config/config.xsl 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/xsl/config/config.xsl 2007-08-06 13:21:58 UTC (rev 699) @@ -8,6 +8,11 @@ <!-- ============================================================================================= --> + <xsl:variable name="style" select="'margin-left:50px;'"/> + <xsl:variable name="width" select="'70px'"/> + + <!-- ============================================================================================= --> + <xsl:template mode="script" match="/"> <script type="text/javascript" src="{/root/gui/url}/scripts/core/kernel/kernel.js"/> <script type="text/javascript" src="{/root/gui/url}/scripts/core/gui/gui.js"/> @@ -44,6 +49,7 @@ <xsl:call-template name="proxy"/> <xsl:call-template name="feedback"/> <xsl:call-template name="removedMetadata"/> + <xsl:call-template name="ldap"/> </xsl:template> <!-- ============================================================================================= --> @@ -51,16 +57,18 @@ <xsl:template name="site"> <h1 align="left"><xsl:value-of select="/root/gui/config/site"/></h1> - <table> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/name"/></td> - <td class="padded"><input id="site.name" class="content" type="text" value="" size="30"/></td> - </tr> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/organ"/></td> - <td class="padded"><input id="site.organ" class="content" type="text" value="" size="30"/></td> - </tr> - </table> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/name"/></td> + <td class="padded"><input id="site.name" class="content" type="text" value="" size="30"/></td> + </tr> + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/organ"/></td> + <td class="padded"><input id="site.organ" class="content" type="text" value="" size="30"/></td> + </tr> + </table> + </div> </xsl:template> <!-- ============================================================================================= --> @@ -68,17 +76,19 @@ <xsl:template name="server"> <h1 align="left"><xsl:value-of select="/root/gui/config/server"/></h1> - <table> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/host"/></td> - <td class="padded"><input id="server.host" class="content" type="text" value="" size="30"/></td> - </tr> - - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> - <td class="padded"><input id="server.port" class="content" type="text" value="" size="30"/></td> - </tr> - </table> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/host"/></td> + <td class="padded"><input id="server.host" class="content" type="text" value="" size="30"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> + <td class="padded"><input id="server.port" class="content" type="text" value="" size="30"/></td> + </tr> + </table> + </div> </xsl:template> <!-- ============================================================================================= --> @@ -86,17 +96,19 @@ <xsl:template name="intranet"> <h1 align="left"><xsl:value-of select="/root/gui/config/intranet"/></h1> - <table> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/network"/></td> - <td class="padded"><input id="intranet.network" class="content" type="text" value="" size="30"/></td> - </tr> - - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/netmask"/></td> - <td class="padded"><input id="intranet.netmask" class="content" type="text" value="" size="30"/></td> - </tr> - </table> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/network"/></td> + <td class="padded"><input id="intranet.network" class="content" type="text" value="" size="30"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/netmask"/></td> + <td class="padded"><input id="intranet.netmask" class="content" type="text" value="" size="30"/></td> + </tr> + </table> + </div> </xsl:template> <!-- ============================================================================================= --> @@ -104,24 +116,26 @@ <xsl:template name="z3950"> <h1 align="left"><xsl:value-of select="/root/gui/config/z3950"/></h1> - <table> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/enable"/></td> - <td class="padded"><input id="z3950.enable" class="content" type="checkbox"/></td> - </tr> - - <tr> - <td/> - <td> - <table id="z3950.subpanel"> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> - <td class="padded"><input id="z3950.port" class="content" type="text" value="" size="20"/></td> - </tr> - </table> - </td> - </tr> - </table> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/enable"/></td> + <td class="padded"><input id="z3950.enable" class="content" type="checkbox"/></td> + </tr> + + <tr> + <td/> + <td> + <table id="z3950.subpanel"> + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> + <td class="padded"><input id="z3950.port" class="content" type="text" value="" size="20"/></td> + </tr> + </table> + </td> + </tr> + </table> + </div> </xsl:template> <!-- ============================================================================================= --> @@ -129,28 +143,30 @@ <xsl:template name="proxy"> <h1 align="left"><xsl:value-of select="/root/gui/config/proxy"/></h1> - <table> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/use"/></td> - <td class="padded"><input id="proxy.use" class="content" type="checkbox" value=""/></td> - </tr> - <tr> - <td/> - <td> - <table id="proxy.subpanel"> - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/host"/></td> - <td class="padded"><input id="proxy.host" class="content" type="text" value="" size="20"/></td> - </tr> - - <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> - <td class="padded"><input id="proxy.port" class="content" type="text" value="" size="20"/></td> - </tr> - </table> - </td> - </tr> - </table> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/use"/></td> + <td class="padded"><input id="proxy.use" class="content" type="checkbox" value=""/></td> + </tr> + <tr> + <td/> + <td> + <table id="proxy.subpanel"> + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/host"/></td> + <td class="padded"><input id="proxy.host" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> + <td class="padded"><input id="proxy.port" class="content" type="text" value="" size="20"/></td> + </tr> + </table> + </td> + </tr> + </table> + </div> </xsl:template> <!-- ============================================================================================= --> @@ -158,37 +174,191 @@ <xsl:template name="feedback"> <h1 align="left"><xsl:value-of select="/root/gui/config/feedback"/></h1> + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/email"/></td> + <td class="padded"><input id="feedback.email" class="content" type="text" value=""/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/smtpHost"/></td> + <td class="padded"><input id="feedback.mail.host" class="content" type="text" value=""/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/smtpPort"/></td> + <td class="padded"><input id="feedback.mail.port" class="content" type="text" value=""/></td> + </tr> + </table> + </div> + </xsl:template> + + <!-- ============================================================================================= --> + + <xsl:template name="removedMetadata"> + <h1 align="left"><xsl:value-of select="/root/gui/config/removedMetadata"/></h1> + + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded" width="{$width}"><xsl:value-of select="/root/gui/config/dir"/></td> + <td class="padded"><input id="removedMd.dir" class="content" type="text" value=""/></td> + </tr> + </table> + </div> + </xsl:template> + + <!-- ============================================================================================= --> + <!-- === LDAP panels === --> + <!-- ============================================================================================= --> + + <xsl:template name="ldap"> + <h1 align="left"><xsl:value-of select="/root/gui/config/ldap"/></h1> + + <div align="left" style="{$style}"> + <table> + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/use"/></td> + <td class="padded"><input id="ldap.use" class="content" type="checkbox" value=""/></td> + </tr> + <tr> + <td/> + <td> + <table id="ldap.subpanel"> + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/host"/></td> + <td class="padded"><input id="ldap.host" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> + <td class="padded"><input id="ldap.port" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/defProfile"/></td> + <td class="padded"><xsl:call-template name="ldapDefProfile"/></td> + </tr> + + <!-- login account --> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/login"/></td> + <td/> + </tr> + <tr> + <td/> + <td class="padded"><xsl:call-template name="ldapLogin"/></td> + </tr> + + <!-- distinguished names --> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/distNames"/></td> + <td/> + </tr> + <tr> + <td/> + <td class="padded"><xsl:call-template name="ldapDistNames"/></td> + </tr> + + <!-- user's attributes --> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/userAttribs"/></td> + <td/> + </tr> + <tr> + <td/> + <td class="padded"><xsl:call-template name="ldapUserAttribs"/></td> + </tr> + </table> + </td> + </tr> + </table> + </div> + </xsl:template> + + <!-- ============================================================================================= --> + + <xsl:template name="ldapDefProfile"> + <select class="content" size="1" name="profile" id="ldap.defProfile"> + <!--option value="Administrator"> + <xsl:value-of select="/root/gui/strings/Administrator"/> + </option--> + + <!--option value="UserAdmin"> + <xsl:value-of select="/root/gui/strings/UserAdmin"/> + </option--> + + <option value="Reviewer"> + <xsl:value-of select="/root/gui/strings/Reviewer"/> + </option> + + <option value="Editor"> + <xsl:value-of select="/root/gui/strings/Editor"/> + </option> + + <option value="RegisteredUser"> + <xsl:value-of select="/root/gui/strings/RegisteredUser"/> + </option> + </select> + </xsl:template> + + <!-- ============================================================================================= --> + + <xsl:template name="ldapLogin"> <table> <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/email"/></td> - <td class="padded"><input id="feedback.email" class="content" type="text" value=""/></td> + <td class="padded" width="60px"><xsl:value-of select="/root/gui/config/userDN"/></td> + <td class="padded"><input id="ldap.userDN" class="content" type="text" value="" size="20"/></td> </tr> - + <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/smtpHost"/></td> - <td class="padded"><input id="feedback.mail.host" class="content" type="text" value=""/></td> + <td class="padded"><xsl:value-of select="/root/gui/config/password"/></td> + <td class="padded"><input id="ldap.password" class="content" type="password" value="" size="20"/></td> </tr> + </table> + </xsl:template> + + <!-- ============================================================================================= --> + + <xsl:template name="ldapDistNames"> + <table> + <tr> + <td class="padded" width="60px"><xsl:value-of select="/root/gui/config/baseDN"/></td> + <td class="padded"><input id="ldap.baseDN" class="content" type="text" value="" size="20"/></td> + </tr> <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/smtpPort"/></td> - <td class="padded"><input id="feedback.mail.port" class="content" type="text" value=""/></td> + <td class="padded"><xsl:value-of select="/root/gui/config/usersDN"/></td> + <td class="padded"><input id="ldap.usersDN" class="content" type="text" value="" size="20"/></td> </tr> </table> </xsl:template> - + <!-- ============================================================================================= --> - - <xsl:template name="removedMetadata"> - <h1 align="left"><xsl:value-of select="/root/gui/config/removedMetadata"/></h1> - + + <xsl:template name="ldapUserAttribs"> <table> <tr> - <td class="padded"><xsl:value-of select="/root/gui/config/dir"/></td> - <td class="padded"><input id="removedMd.dir" class="content" type="text" value=""/></td> - </tr> + <td class="padded" width="60px"><xsl:value-of select="/root/gui/config/name"/></td> + <td class="padded"><input id="ldap.nameAttr" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/password"/></td> + <td class="padded"><input id="ldap.passwordAttr" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/profile"/></td> + <td class="padded"><input id="ldap.profileAttr" class="content" type="text" value="" size="20"/></td> + </tr> </table> </xsl:template> - + <!-- ============================================================================================= --> <!-- === Buttons --> <!-- ============================================================================================= --> Modified: trunk/web/geonetwork/xsl/ownership/client-group-row.xsl =================================================================== --- trunk/web/geonetwork/xsl/ownership/client-group-row.xsl 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/xsl/ownership/client-group-row.xsl 2007-08-06 13:21:58 UTC (rev 699) @@ -12,12 +12,12 @@ <xsl:template match="/root/group"> - <tr id="group.{id}"> + <tr id="{id}"> <!-- source group - - - - - - - - - - - - - - - - - - - - - - --> <td class="padded"> - <span id="{id}"> + <span> <xsl:value-of select="label/*[name() = /root/env/language]"/> </span> </td> @@ -25,19 +25,19 @@ <!-- target group - - - - - - - - - - - - - - - - - - - - - - --> <td class="padded"> - <select id="source.user" class="content" name="type" size="1"/> + <select id="target.group" class="content" name="type" size="1"/> </td> <!-- target user - - - - - - - - - - - - - - - - - - - - - - --> <td class="padded"> - <select id="source.user" class="content" name="type" size="1"/> + <select id="target.user" class="content" name="type" size="1"/> </td> <!-- operation - - - - - - - - - - - - - - - - - - - - - - --> <td class="padded"> - <button class="content" onclick="ownership.transfer('group.{id}')"> + <button class="content" onclick="ownership.transfer('{id}')"> <xsl:value-of select="/root/strings/transfer"/> </button> </td> Modified: trunk/web/geonetwork/xsl/ownership/transfer-ownership.xsl =================================================================== --- trunk/web/geonetwork/xsl/ownership/transfer-ownership.xsl 2007-08-02 14:39:20 UTC (rev 698) +++ trunk/web/geonetwork/xsl/ownership/transfer-ownership.xsl 2007-08-06 13:21:58 UTC (rev 699) @@ -57,10 +57,10 @@ <table id="group.list"> <tr> - <th class="padded"><xsl:value-of select="/root/gui/ownership/sourceGroup"/></th> - <th class="padded"><xsl:value-of select="/root/gui/ownership/targetGroup"/></th> - <th class="padded"><xsl:value-of select="/root/gui/ownership/targetUser"/></th> - <th class="padded"><xsl:value-of select="/root/gui/ownership/operation"/></th> + <th class="padded"><b><xsl:value-of select="/root/gui/ownership/sourceGroup"/></b></th> + <th class="padded"><b><xsl:value-of select="/root/gui/ownership/targetGroup"/></b></th> + <th class="padded"><b><xsl:value-of select="/root/gui/ownership/targetUser"/></b></th> + <th class="padded"><b><xsl:value-of select="/root/gui/ownership/operation"/></b></th> </tr> </table> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-06 22:08:38
|
Revision: 701 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=701&view=rev Author: acarboni Date: 2007-08-06 15:08:40 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Added LDAP authentication Modified Paths: -------------- trunk/docs/changes.txt trunk/docs/lyx/server-reference.lyx trunk/gast/setup/db/Settings.ddf trunk/src/org/fao/geonet/kernel/setting/SettingManager.java trunk/src/org/fao/geonet/services/config/Set.java trunk/src/org/fao/geonet/services/login/Login.java trunk/web/geonetwork/loc/en/xml/config.xml trunk/web/geonetwork/scripts/config/model.js trunk/web/geonetwork/scripts/config/view.js trunk/web/geonetwork/xsl/xml/config.xsl Added Paths: ----------- trunk/src/org/fao/geonet/services/login/LDAPContext.java trunk/src/org/fao/geonet/services/login/LDAPUtil.java Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/docs/changes.txt 2007-08-06 22:08:40 UTC (rev 701) @@ -1,5 +1,23 @@ ================================================================================ === +=== GeoNetwork 2.1.0 RC : List of changes +=== +================================================================================ + +- Added simple LDAP authentication + +-------------------------------------------------------------------------------- +--- Changes +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +--- Bugs fixed +-------------------------------------------------------------------------------- + +- Fixed start-geonetwork.bat script + +================================================================================ +=== === GeoNetwork 2.1.0 beta5 : List of changes === ================================================================================ Modified: trunk/docs/lyx/server-reference.lyx =================================================================== --- trunk/docs/lyx/server-reference.lyx 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/docs/lyx/server-reference.lyx 2007-08-06 22:08:40 UTC (rev 701) @@ -10641,8 +10641,10 @@ \end_deeper \begin_layout Itemize +\family sans \series bold removedMetadata +\family default \series default : This container contains settings about removed metadata. \end_layout @@ -10650,14 +10652,217 @@ \begin_deeper \begin_layout Itemize +\family sans \series bold dir +\family default \series default : This folder will contain removed metadata in MEF format. It gets populated when the user deletes a metadata using the web interface. \end_layout \end_deeper +\begin_layout Itemize + +\family sans +\series bold +ldap +\family default +\series default + : Parameters for LDAP authentication +\end_layout + +\begin_deeper +\begin_layout Itemize + +\family sans +\series bold +use +\family default +\series default + ( +\emph on +boolean +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +host +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +port +\family default +\series default + ( +\emph on +integer +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +defaultProfile +\family default +\series default + ( +\emph on +string +\emph default +) : Default GeoNetwork's profile to use when the +\family sans +profile +\family default + user attribute does not exist. +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +login +\end_layout + +\begin_deeper +\begin_layout Itemize + +\family sans +\series bold +userDN +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +password +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\end_deeper +\begin_layout Itemize + +\family sans +\series bold +distinguishedNames +\end_layout + +\begin_deeper +\begin_layout Itemize + +\family sans +\series bold +base +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +users +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\end_deeper +\begin_layout Itemize + +\family sans +\series bold +userAttribs +\family default +\series default + : A container for user attributes present into the LDAP directory that + must be retrieved and used to create the user in GeoNetwork. +\end_layout + +\begin_deeper +\begin_layout Itemize + +\family sans +\series bold +name +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +password +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\begin_layout Itemize + +\family sans +\series bold +profile +\family default +\series default + ( +\emph on +string +\emph default +) +\end_layout + +\end_deeper +\end_deeper \begin_layout Section Harvesting nodes \end_layout Modified: trunk/gast/setup/db/Settings.ddf =================================================================== --- trunk/gast/setup/db/Settings.ddf 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/gast/setup/db/Settings.ddf 2007-08-06 22:08:40 UTC (rev 701) @@ -48,3 +48,21 @@ 70 1 removedMetadata 71 70 dir WEB-INF/removed + +80 1 ldap +81 80 use false +82 80 host +83 80 port +84 80 defaultProfile RegisteredUser +85 80 login +86 80 distinguishedNames +87 80 userAttribs + +90 85 userDN cn=Manager +91 85 password +100 86 base dc=fao,dc=org +101 86 users ou=people + +110 87 name cn +111 87 password userPassword +112 87 profile profile Modified: trunk/src/org/fao/geonet/kernel/setting/SettingManager.java =================================================================== --- trunk/src/org/fao/geonet/kernel/setting/SettingManager.java 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/src/org/fao/geonet/kernel/setting/SettingManager.java 2007-08-06 22:08:40 UTC (rev 701) @@ -314,6 +314,30 @@ } //--------------------------------------------------------------------------- + + public boolean getValueAsBool(String path) + { + String value = getValue(path); + + if (value == null) + return false; + + return value.equals("true"); + } + + //--------------------------------------------------------------------------- + + public Integer getValueAsInt(String path) + { + String value = getValue(path); + + if (value == null || value.trim().length() == 0) + return null; + + return new Integer(value); + } + + //--------------------------------------------------------------------------- //--- //--- Private methods //--- Modified: trunk/src/org/fao/geonet/services/config/Set.java =================================================================== --- trunk/src/org/fao/geonet/services/config/Set.java 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/src/org/fao/geonet/services/config/Set.java 2007-08-06 22:08:40 UTC (rev 701) @@ -86,19 +86,37 @@ { new ConfigEntry(ConfigEntry.Type.STRING, true, "site/name", "system/site/name"), new ConfigEntry(ConfigEntry.Type.STRING, false, "site/organization", "system/site/organization"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "server/host", "system/server/host"), new ConfigEntry(ConfigEntry.Type.INT, false, "server/port", "system/server/port"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "intranet/network", "system/intranet/network"), new ConfigEntry(ConfigEntry.Type.STRING, true, "intranet/netmask", "system/intranet/netmask"), + new ConfigEntry(ConfigEntry.Type.BOOL, true, "z3950/enable", "system/z3950/enable"), new ConfigEntry(ConfigEntry.Type.INT, false, "z3950/port", "system/z3950/port"), + new ConfigEntry(ConfigEntry.Type.BOOL, true, "proxy/use", "system/proxy/use"), new ConfigEntry(ConfigEntry.Type.STRING, false, "proxy/host", "system/proxy/host"), new ConfigEntry(ConfigEntry.Type.INT, false, "proxy/port", "system/proxy/port"), + new ConfigEntry(ConfigEntry.Type.STRING, false, "feedback/email", "system/feedback/email"), new ConfigEntry(ConfigEntry.Type.STRING, false, "feedback/mailServer/host", "system/feedback/mailServer/host"), new ConfigEntry(ConfigEntry.Type.INT, false, "feedback/mailServer/port", "system/feedback/mailServer/port"), - new ConfigEntry(ConfigEntry.Type.STRING, true, "removedMetadata/dir", "system/removedMetadata/dir") + + new ConfigEntry(ConfigEntry.Type.STRING, true, "removedMetadata/dir", "system/removedMetadata/dir"), + + new ConfigEntry(ConfigEntry.Type.BOOL, true, "ldap/use", "system/ldap/use"), + new ConfigEntry(ConfigEntry.Type.STRING, false, "ldap/host", "system/ldap/host"), + new ConfigEntry(ConfigEntry.Type.INT, false, "ldap/port", "system/ldap/port"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/defaultProfile", "system/ldap/defaultProfile"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/login/userDN", "system/ldap/login/userDN"), + new ConfigEntry(ConfigEntry.Type.STRING, false, "ldap/login/password", "system/ldap/login/password"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/distinguishedNames/base", "system/ldap/distinguishedNames/base"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/distinguishedNames/users","system/ldap/distinguishedNames/users"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/userAttribs/name", "system/ldap/userAttribs/name"), + new ConfigEntry(ConfigEntry.Type.STRING, true, "ldap/userAttribs/password", "system/ldap/userAttribs/password"), + new ConfigEntry(ConfigEntry.Type.STRING, false, "ldap/userAttribs/profile", "system/ldap/userAttribs/profile") }; } Added: trunk/src/org/fao/geonet/services/login/LDAPContext.java =================================================================== --- trunk/src/org/fao/geonet/services/login/LDAPContext.java (rev 0) +++ trunk/src/org/fao/geonet/services/login/LDAPContext.java 2007-08-06 22:08:40 UTC (rev 701) @@ -0,0 +1,197 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.services.login; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import jeeves.utils.Log; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.setting.SettingManager; + +//============================================================================= + +class LDAPContext +{ + //-------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //-------------------------------------------------------------------------- + + public LDAPContext(SettingManager sm) + { + String prefix = "system/ldap"; + + use = sm.getValueAsBool(prefix +"/use"); + host = sm.getValue (prefix +"/host"); + port = sm.getValueAsInt (prefix +"/port"); + defProfile = sm.getValue (prefix +"/defaultProfile"); + loginUserDN = sm.getValue (prefix +"/login/userDN"); + loginPassword = sm.getValue (prefix +"/login/password"); + baseDN = sm.getValue (prefix +"/distinguishedNames/base"); + usersDN = sm.getValue (prefix +"/distinguishedNames/users"); + nameAttr = sm.getValue (prefix +"/userAttribs/name"); + passwordAttr = sm.getValue (prefix +"/userAttribs/password"); + profileAttr = sm.getValue (prefix +"/userAttribs/profile"); + + if (profileAttr.trim().length() == 0) + profileAttr = null; + + //--- init set of allowed profiles + + profiles.add("Reviewer"); + profiles.add("Editor"); + profiles.add("RegisteredUser"); + } + + //-------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //-------------------------------------------------------------------------- + + public boolean isInUse() { return use; } + + //-------------------------------------------------------------------------- + + public LDAPInfo lookUp(String username, String password) + { + try + { + DirContext dc = LDAPUtil.openContext(getUrl(), loginUserDN, loginPassword); + String path = "uid="+ username +","+ usersDN +","+ baseDN; + + Map<String, ? extends List<Object>> attr = LDAPUtil.getNodeInfo(dc, path); + dc.close(); + + if (attr == null) + { + Log.info(Geonet.LDAP, "Username not found :"+ username); + return null; + } + else + { + LDAPInfo info = new LDAPInfo(); + + info.username = username; + info.password = password; + info.name = get(attr, nameAttr); + info.profile = (profileAttr == null) + ? defProfile + : get(attr, profileAttr); + + if (!password.equals(get(attr, passwordAttr))) + { + Log.info(Geonet.LDAP, "Username found but bad password :"+ username); + return null; + } + + if (!profiles.contains(info.profile)) + { + Log.info(Geonet.LDAP, "Skipping user with unknown profile"); + Log.info(Geonet.LDAP, " (C) Username :"+ info.username); + Log.info(Geonet.LDAP, " (C) Profile :"+ info.profile); + return null; + } + + return info; + } + } + catch(NamingException e) + { + Log.info(Geonet.LDAP, "Raised exception during LDAP access"); + Log.info(Geonet.LDAP, " (C) Message :"+ e.getMessage()); + return null; + } + } + + //-------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //-------------------------------------------------------------------------- + + private String getUrl() + { + return "ldap://"+ host +":" + ((port != null) ? port : "389"); + } + + //-------------------------------------------------------------------------- + + private String get(Map<String, ? extends List<Object>> attr, String name) + { + List<Object> values = attr.get(name); + + if (values == null) + { + Log.debug(Geonet.LDAP, "Attribute '"+ name +"' does not exist"); + return null; + } + + Object obj = values.get(0); + + if (obj != null) + Log.debug(Geonet.LDAP, "Attribute '"+ name +"' is of type : "+obj.getClass().getSimpleName()); + else + Log.debug(Geonet.LDAP, "Attribute '"+ name +"' is null"); + + return (obj == null) ? null : obj.toString(); + } + + //-------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //-------------------------------------------------------------------------- + + private boolean use; + private String host; + private Integer port; + private String defProfile; + private String loginUserDN; + private String loginPassword; + private String baseDN; + private String usersDN; + private String nameAttr; + private String passwordAttr; + private String profileAttr; + + private HashSet<String> profiles = new HashSet<String>(); +} + +//============================================================================= + +class LDAPInfo +{ + public String username; + public String password; + public String profile; + public String name; +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/services/login/LDAPUtil.java =================================================================== --- trunk/src/org/fao/geonet/services/login/LDAPUtil.java (rev 0) +++ trunk/src/org/fao/geonet/services/login/LDAPUtil.java 2007-08-06 22:08:40 UTC (rev 701) @@ -0,0 +1,130 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.services.login; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import jeeves.utils.Log; +import org.fao.geonet.constants.Geonet; + +//============================================================================= + +public class LDAPUtil +{ + //-------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //-------------------------------------------------------------------------- + + public static DirContext openContext(String url, String username, String password) throws NamingException + { + try + { + Log.info(Geonet.LDAP, "Opening LDAP context on :"+ url); + + Hashtable<String,String> env = new Hashtable<String,String>(); + + env.put(Context.SECURITY_PRINCIPAL, username); + env.put(Context.SECURITY_CREDENTIALS, password); + + DirContext dc = new InitialDirContext(env); + + return (DirContext) dc.lookup(url); + } + catch(NamingException e) + { + Log.warning(Geonet.LDAP, "Cannot open context on : "+ url); + Log.warning(Geonet.LDAP, " (C) Reason : "+ e.getMessage()); + throw e; + } + } + + //-------------------------------------------------------------------------- + + public static Map<String, ? extends List<Object>> getNodeInfo(DirContext dc, + String dname) throws NamingException + { + try + { + Log.info(Geonet.LDAP, "Retrieving information for :"+ dname); + + //--- retrieve all attributes + + Attributes attrs = dc.getAttributes(dname); + + NamingEnumeration<? extends Attribute> en = attrs.getAll(); + + Map<String, ArrayList<Object>> info = new HashMap<String, ArrayList<Object>>(); + + //--- scan all attributes + + while (en.hasMore()) + { + Attribute attr = en.next(); + + String id = attr.getID(); + + //--- retrieve attrib's list of values (create it if the case) + + ArrayList<Object> values = info.get(id); + + if (values == null) + { + values = new ArrayList<Object>(); + info.put(id, values); + } + + //--- loop on all attribute's values + + NamingEnumeration valueEnum = attr.getAll(); + + while (valueEnum.hasMore()) + values.add(valueEnum.next()); + } + + return info; + } + catch(NamingException e) + { + Log.warning(Geonet.LDAP, "Cannot retrieve node info for : "+ dname); + Log.warning(Geonet.LDAP, " (C) Reason : "+ e.getMessage()); + throw e; + } + } +} + +//============================================================================= + + Modified: trunk/src/org/fao/geonet/services/login/Login.java =================================================================== --- trunk/src/org/fao/geonet/services/login/Login.java 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/src/org/fao/geonet/services/login/Login.java 2007-08-06 22:08:40 UTC (rev 701) @@ -23,16 +23,18 @@ package org.fao.geonet.services.login; +import java.sql.SQLException; import java.util.List; -import java.util.Vector; import jeeves.exceptions.UserLoginEx; import jeeves.interfaces.Service; import jeeves.resources.dbms.Dbms; import jeeves.server.ServiceConfig; import jeeves.server.context.ServiceContext; import jeeves.utils.Util; +import org.fao.geonet.GeonetContext; import org.fao.geonet.constants.Geonet; import org.fao.geonet.constants.Params; +import org.fao.geonet.kernel.setting.SettingManager; import org.jdom.Element; //============================================================================= @@ -58,37 +60,85 @@ public Element exec(Element params, ServiceContext context) throws Exception { - String user = Util.getParam(params, Params.USERNAME); - String pass = Util.getParam(params, Params.PASSWORD); + String username = Util.getParam(params, Params.USERNAME); + String password = Util.getParam(params, Params.PASSWORD); + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + SettingManager sm = gc.getSettingManager(); + + Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); + + LDAPContext lc = new LDAPContext(sm); + + if (!isAdmin(dbms, username) && lc.isInUse()) + { + LDAPInfo info = lc.lookUp(username, password); + + if (info == null) + throw new UserLoginEx(username); + + updateUser(context, dbms, info); + } + //--- attempt to load user from db - Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); String query = "SELECT * FROM Users WHERE username = ? AND password = ?"; - Element elUser = dbms.select(query, user,Util.scramble(pass)); + List list = dbms.select(query, username, Util.scramble(password)).getChildren(); - List list = elUser.getChildren(); - if (list.size() == 0) - throw new UserLoginEx(user); - else - { - elUser = (Element) list.get(0); + throw new UserLoginEx(username); - String sId = elUser.getChildText(Geonet.Elem.ID); - String sName = elUser.getChildText(Geonet.Elem.NAME); - String sSurname = elUser.getChildText(Geonet.Elem.SURNAME); - String sProfile = elUser.getChildText(Geonet.Elem.PROFILE); + Element user = (Element) list.get(0); - context.info("User '" + user + "' logged in."); + String sId = user.getChildText(Geonet.Elem.ID); + String sName = user.getChildText(Geonet.Elem.NAME); + String sSurname = user.getChildText(Geonet.Elem.SURNAME); + String sProfile = user.getChildText(Geonet.Elem.PROFILE); - context.getUserSession().authenticate(sId, user, sName, sSurname, sProfile); - } + context.info("User '" + user + "' logged in."); + context.getUserSession().authenticate(sId, username, sName, sSurname, sProfile); return new Element("ok"); } + + //-------------------------------------------------------------------------- + + private boolean isAdmin(Dbms dbms, String username) throws SQLException + { + String query = "SELECT id FROM Users WHERE username=? AND profile=?"; + + List list = dbms.select(query, username, "Administrator").getChildren(); + + return (list.size() != 0); + } + + //-------------------------------------------------------------------------- + + private void updateUser(ServiceContext context, Dbms dbms, LDAPInfo info) throws SQLException + { + //--- update user information into the database + + String query = "UPDATE Users SET password=?, name=?, profile=? WHERE username=?"; + + int res = dbms.execute(query, info.password, info.name, info.profile, info.username); + + //--- if the user was not found --> add it + + if (res == 0) + { + int id = context.getSerialFactory().getSerial(dbms, "Users"); + + query = "INSERT INTO Users(id, username, password, surname, name, profile) "+ + "VALUES(?,?,?,?,?,?)"; + + dbms.execute(query, id, info.username, info.password, "(LDAP)", info.name, info.profile); + } + + dbms.commit(); + } } //============================================================================= + Modified: trunk/web/geonetwork/loc/en/xml/config.xml =================================================================== --- trunk/web/geonetwork/loc/en/xml/config.xml 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/web/geonetwork/loc/en/xml/config.xml 2007-08-06 22:08:40 UTC (rev 701) @@ -27,6 +27,18 @@ <removedMetadata>Removed metadata</removedMetadata> <dir>Directory</dir> + <ldap>LDAP Authentication</ldap> + <defProfile>Default profile</defProfile> + <login>Login</login> + <userDN>User DN</userDN> + <distNames>Distinguished names</distNames> + <baseDN>Base</baseDN> + <usersDN>Users</usersDN> + <userAttribs>User's attributes</userAttribs> + <name>Name</name> + <password>Password</password> + <profile>Profile</profile> + <!-- Buttons --> <save>Save</save> Modified: trunk/web/geonetwork/scripts/config/model.js =================================================================== --- trunk/web/geonetwork/scripts/config/model.js 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/web/geonetwork/scripts/config/model.js 2007-08-06 22:08:40 UTC (rev 701) @@ -42,7 +42,19 @@ FEEDBACK_EMAIL : xml.evalXPath(node, 'feedback/email'), FEEDBACK_MAIL_HOST: xml.evalXPath(node, 'feedback/mailServer/host'), FEEDBACK_MAIL_PORT: xml.evalXPath(node, 'feedback/mailServer/port'), - REMOVEDMD_DIR : xml.evalXPath(node, 'removedMetadata/dir') + REMOVEDMD_DIR : xml.evalXPath(node, 'removedMetadata/dir'), + + LDAP_USE : xml.evalXPath(node, 'ldap/use'), + LDAP_HOST : xml.evalXPath(node, 'ldap/host'), + LDAP_PORT : xml.evalXPath(node, 'ldap/port'), + LDAP_DEF_PROFILE : xml.evalXPath(node, 'ldap/defaultProfile'), + LDAP_USERDN : xml.evalXPath(node, 'ldap/login/userDN'), + LDAP_PASSWORD : xml.evalXPath(node, 'ldap/login/password'), + LDAP_DN_BASE : xml.evalXPath(node, 'ldap/distinguishedNames/base'), + LDAP_DN_USERS : xml.evalXPath(node, 'ldap/distinguishedNames/users'), + LDAP_ATTR_NAME : xml.evalXPath(node, 'ldap/userAttribs/name'), + LDAP_ATTR_PASSWORD: xml.evalXPath(node, 'ldap/userAttribs/password'), + LDAP_ATTR_PROFILE : xml.evalXPath(node, 'ldap/userAttribs/profile') } this.getConfigCB(data); @@ -110,6 +122,25 @@ ' <removedMetadata>'+ ' <dir>{REMOVEDMD_DIR}</dir>'+ ' </removedMetadata>'+ +' <ldap>'+ +' <use>{LDAP_USE}</use>'+ +' <host>{LDAP_HOST}</host>'+ +' <port>{LDAP_PORT}</port>'+ +' <defaultProfile>{LDAP_DEF_PROFILE}</defaultProfile>'+ +' <login>'+ +' <userDN>{LDAP_USERDN}</userDN>'+ +' <password>{LDAP_PASSWORD}</password>'+ +' </login>'+ +' <distinguishedNames>'+ +' <base>{LDAP_DN_BASE}</base>'+ +' <users>{LDAP_DN_USERS}</users>'+ +' </distinguishedNames>'+ +' <userAttribs>'+ +' <name>{LDAP_ATTR_NAME}</name>'+ +' <password>{LDAP_ATTR_PASSWORD}</password>'+ +' <profile>{LDAP_ATTR_PROFILE}</profile>'+ +' </userAttribs>'+ +' </ldap>'+ '</config>'; //===================================================================================== Modified: trunk/web/geonetwork/scripts/config/view.js =================================================================== --- trunk/web/geonetwork/scripts/config/view.js 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/web/geonetwork/scripts/config/view.js 2007-08-06 22:08:40 UTC (rev 701) @@ -33,11 +33,21 @@ { id:'proxy.host', type:'hostname' }, { id:'proxy.port', type:'integer', minValue:21, maxValue:65535, empty:true }, - { id:'removedMd.dir', type:'length', minSize :0, maxSize :200 } + { id:'removedMd.dir', type:'length', minSize :0, maxSize :200 }, + + { id:'ldap.host', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.host', type:'hostname' }, + { id:'ldap.port', type:'integer', minValue:80, maxValue:65535, empty:true }, + { id:'ldap.userDN', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.baseDN', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.usersDN', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.nameAttr', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.passwordAttr', type:'length', minSize :1, maxSize :200 } ]); this.z3950Shower = new Shower('z3950.enable', 'z3950.subpanel'); this.proxyShower = new Shower('proxy.use', 'proxy.subpanel'); + this.ldapShower = new Shower('ldap.use', 'ldap.subpanel'); } //===================================================================================== @@ -72,8 +82,21 @@ $('removedMd.dir').value = data['REMOVEDMD_DIR']; + $('ldap.use') .checked = data['LDAP_USE'] == 'true'; + $('ldap.host') .value = data['LDAP_HOST']; + $('ldap.port') .value = data['LDAP_PORT']; + $('ldap.defProfile') .value = data['LDAP_DEF_PROFILE']; + $('ldap.userDN') .value = data['LDAP_USERDN']; + $('ldap.password') .value = data['LDAP_PASSWORD']; + $('ldap.baseDN') .value = data['LDAP_DN_BASE']; + $('ldap.usersDN') .value = data['LDAP_DN_USERS']; + $('ldap.nameAttr') .value = data['LDAP_ATTR_NAME']; + $('ldap.passwordAttr').value = data['LDAP_ATTR_PASSWORD']; + $('ldap.profileAttr') .value = data['LDAP_ATTR_PROFILE']; + this.z3950Shower.update(); this.proxyShower.update(); + this.ldapShower.update(); } //===================================================================================== @@ -108,7 +131,19 @@ FEEDBACK_MAIL_HOST : $('feedback.mail.host').value, FEEDBACK_MAIL_PORT : $('feedback.mail.port').value, - REMOVEDMD_DIR : $('removedMd.dir').value + REMOVEDMD_DIR : $('removedMd.dir').value, + + LDAP_USE : $('ldap.use').checked, + LDAP_HOST : $F('ldap.host'), + LDAP_PORT : $F('ldap.port'), + LDAP_DEF_PROFILE : $F('ldap.defProfile'), + LDAP_USERDN : $F('ldap.userDN'), + LDAP_PASSWORD : $F('ldap.password'), + LDAP_DN_BASE : $F('ldap.baseDN'), + LDAP_DN_USERS : $F('ldap.usersDN'), + LDAP_ATTR_NAME : $F('ldap.nameAttr'), + LDAP_ATTR_PASSWORD : $F('ldap.passwordAttr'), + LDAP_ATTR_PROFILE : $F('ldap.profileAttr') } return data; Modified: trunk/web/geonetwork/xsl/xml/config.xsl =================================================================== --- trunk/web/geonetwork/xsl/xml/config.xsl 2007-08-06 21:57:34 UTC (rev 700) +++ trunk/web/geonetwork/xsl/xml/config.xsl 2007-08-06 22:08:40 UTC (rev 701) @@ -7,13 +7,17 @@ <!-- ============================================================================================= --> <xsl:template match="/system"> - <xsl:variable name="site" select="children/site/children"/> - <xsl:variable name="server" select="children/server/children"/> - <xsl:variable name="intranet" select="children/intranet/children"/> - <xsl:variable name="z3950" select="children/z3950/children"/> - <xsl:variable name="proxy" select="children/proxy/children"/> - <xsl:variable name="feedback" select="children/feedback/children"/> - <xsl:variable name="removedMd" select="children/removedMetadata/children"/> + <xsl:variable name="site" select="children/site/children"/> + <xsl:variable name="server" select="children/server/children"/> + <xsl:variable name="intranet" select="children/intranet/children"/> + <xsl:variable name="z3950" select="children/z3950/children"/> + <xsl:variable name="proxy" select="children/proxy/children"/> + <xsl:variable name="feedback" select="children/feedback/children"/> + <xsl:variable name="removedMd" select="children/removedMetadata/children"/> + <xsl:variable name="ldap" select="children/ldap/children"/> + <xsl:variable name="ldapLogin" select="$ldap/login/children"/> + <xsl:variable name="ldapDisNam" select="$ldap/distinguishedNames/children"/> + <xsl:variable name="ldapUsrAtt" select="$ldap/userAttribs/children"/> <config> <site> @@ -53,6 +57,26 @@ <removedMetadata> <dir><xsl:value-of select="$removedMd/dir/value"/></dir> </removedMetadata> + + <ldap> + <use><xsl:value-of select="$ldap/use/value"/></use> + <host><xsl:value-of select="$ldap/host/value"/></host> + <port><xsl:value-of select="$ldap/port/value"/></port> + <defaultProfile><xsl:value-of select="$ldap/defaultProfile/value"/></defaultProfile> + <login> + <userDN><xsl:value-of select="$ldapLogin/userDN/value"/></userDN> + <password><xsl:value-of select="$ldapLogin/password/value"/></password> + </login> + <distinguishedNames> + <base><xsl:value-of select="$ldapDisNam/base/value"/></base> + <users><xsl:value-of select="$ldapDisNam/users/value"/></users> + </distinguishedNames> + <userAttribs> + <name><xsl:value-of select="$ldapUsrAtt/name/value"/></name> + <password><xsl:value-of select="$ldapUsrAtt/password/value"/></password> + <profile><xsl:value-of select="$ldapUsrAtt/profile/value"/></profile> + </userAttribs> + </ldap> </config> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-08-08 16:05:34
|
Revision: 714 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=714&view=rev Author: e_tajariol Date: 2007-08-08 09:05:20 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Metadata search is now filtered on bbox and region also. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/util/Util.java trunk/web/geonetwork/scripts/gn_search.js trunk/web/geonetwork/xsl/main-page.xsl trunk/web/intermap/scripts/im_bigmap.js trunk/web/intermap/scripts/im_minimap.js Modified: trunk/src/org/wfp/vam/intermap/util/Util.java =================================================================== --- trunk/src/org/wfp/vam/intermap/util/Util.java 2007-08-08 14:39:38 UTC (rev 713) +++ trunk/src/org/wfp/vam/intermap/util/Util.java 2007-08-08 16:05:20 UTC (rev 714) @@ -26,10 +26,10 @@ { try { - float n = Float.parseFloat(params.getChildText("bbnorth")); - float e = Float.parseFloat(params.getChildText("bbeast")); - float s = Float.parseFloat(params.getChildText("bbsouth")); - float w = Float.parseFloat(params.getChildText("bbwest")); + float n = Float.parseFloat(params.getChildText("northBL")); + float e = Float.parseFloat(params.getChildText("eastBL")); + float s = Float.parseFloat(params.getChildText("southBL")); + float w = Float.parseFloat(params.getChildText("westBL")); return new BoundingBox(n, s, e, w); } catch (NullPointerException e) // child not found Modified: trunk/web/geonetwork/scripts/gn_search.js =================================================================== --- trunk/web/geonetwork/scripts/gn_search.js 2007-08-08 14:39:38 UTC (rev 713) +++ trunk/web/geonetwork/scripts/gn_search.js 2007-08-08 16:05:20 UTC (rev 714) @@ -9,7 +9,7 @@ /* */ -function prepareSearch() +function preparePresent() { // Display results area clearNode('resultList'); @@ -25,18 +25,24 @@ /* */ function doMetadataSearch() { - prepareSearch(); + preparePresent(); + var region = $('region').value; + if(region=="") + region=null; + // Load results via AJAX - gn_search($('any') .value); - // FIXME add bb + gn_search($('any') .value, + im_mm_getURLselectedbbox(), + region); } -function gn_search(text, bbn, bbe, bbs, bbw) +function gn_search(text, bb, region) { - var pars = 'any=' + text; -// add bb - + var pars = 'any=' + encodeURIComponent(text) + "&"+bb; + if(region) + pars += "®ion="+region; + var myAjax = new Ajax.Request( '/geonetwork/srv/en/main.search.embedded', { method: 'get', @@ -48,7 +54,7 @@ function gn_present(frompage, topage) { - prepareSearch(); + preparePresent(); var pars = 'from=' + frompage + "&to=" + topage; @@ -74,15 +80,15 @@ $('loadingMD').hide(); } -function gn_toggleMetadata(id) +/*function gn_toggleMetadata(id) { var parent = $('mdwhiteboard_' + id); if (parent.firstChild) - gn_hideMetadata(id); + gn_hideMetadata(id); else - gn_showMetadata(id); + gn_showMetadata(id); } - +*/ function gn_showMetadata(id) { var pars = 'id=' + id + '&currTab=simple'; Modified: trunk/web/geonetwork/xsl/main-page.xsl =================================================================== --- trunk/web/geonetwork/xsl/main-page.xsl 2007-08-08 14:39:38 UTC (rev 713) +++ trunk/web/geonetwork/xsl/main-page.xsl 2007-08-08 16:05:20 UTC (rev 714) @@ -725,7 +725,7 @@ <!-- regions combobox --> - <select class="content" name="region"> + <select class="content" name="region" id="region"> <option value=""> <xsl:if test="/root/gui/searchDefaults/theme='_any_'"> <xsl:attribute name="selected"/> @@ -1164,8 +1164,8 @@ <tr> <td align="right" colspan="2"> <!-- regions combobox --> - <select class="content" name="region"> - <option value=""> + <select class="content" name="region" id="region"> + <option value=""> <xsl:if test="/root/gui/searchDefaults/theme='_any_'"> <xsl:attribute name="selected"/> </xsl:if> Modified: trunk/web/intermap/scripts/im_bigmap.js =================================================================== --- trunk/web/intermap/scripts/im_bigmap.js 2007-08-08 14:39:38 UTC (rev 713) +++ trunk/web/intermap/scripts/im_bigmap.js 2007-08-08 16:05:20 UTC (rev 714) @@ -99,10 +99,10 @@ function im_bm_getURLbbox() { - return "bbnorth="+im_bm_north+ - "&bbeast="+im_bm_east+ - "&bbsouth="+im_bm_south+ - "&bbwest="+im_bm_west; + return "northBL="+im_bm_north+ + "&eastBL="+im_bm_east+ + "&southBL="+im_bm_south+ + "&westBL="+im_bm_west; } Modified: trunk/web/intermap/scripts/im_minimap.js =================================================================== --- trunk/web/intermap/scripts/im_minimap.js 2007-08-08 14:39:38 UTC (rev 713) +++ trunk/web/intermap/scripts/im_minimap.js 2007-08-08 16:05:20 UTC (rev 714) @@ -113,10 +113,7 @@ function im_mm_getURLbbox() { if(im_mm_north) - return "bbnorth="+im_mm_north+ - "&bbeast="+im_mm_east+ - "&bbsouth="+im_mm_south+ - "&bbwest="+im_mm_west; + return im_urlizebb(im_mm_north, im_mm_east, im_mm_south, im_mm_west); else return null; } @@ -131,12 +128,21 @@ function im_urlizebb(n, e, s, w) { - return "bbnorth="+n+ - "&bbeast="+e+ - "&bbsouth="+s+ - "&bbwest="+w; + return "northBL="+n+ + "&eastBL="+e+ + "&southBL="+s+ + "&westBL="+w; } +function im_mm_getURLselectedbbox() +{ + return im_urlizebb( + im_mm_ctrl_n.value, + im_mm_ctrl_e.value, + im_mm_ctrl_s.value, + im_mm_ctrl_w.value); +} + /***************************************************************************** * * MiniMap operations (zoom, pan, identify) @@ -367,6 +373,9 @@ Element.remove(im_mm_aoibox); im_mm_aoibox = null; } + + // set back full mm bbox into input fields + im_mm_setTextCoords(im_mm_north, im_mm_east, im_mm_south, im_mm_west); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-10 14:08:50
|
Revision: 725 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=725&view=rev Author: acarboni Date: 2007-08-10 07:08:51 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Some fixes. Now the editors' list contains only editors with associated metadata Modified Paths: -------------- trunk/web/geonetwork/WEB-INF/config-metadata.xml trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml trunk/web/geonetwork/scripts/ownership/model.js trunk/web/geonetwork/scripts/ownership/transfer-ownership.js trunk/web/geonetwork/xml/user-profiles.xml Added Paths: ----------- trunk/src/org/fao/geonet/services/ownership/Editors.java Added: trunk/src/org/fao/geonet/services/ownership/Editors.java =================================================================== --- trunk/src/org/fao/geonet/services/ownership/Editors.java (rev 0) +++ trunk/src/org/fao/geonet/services/ownership/Editors.java 2007-08-10 14:08:51 UTC (rev 725) @@ -0,0 +1,147 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.services.ownership; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import jeeves.interfaces.Service; +import jeeves.resources.dbms.Dbms; +import jeeves.server.ServiceConfig; +import jeeves.server.UserSession; +import jeeves.server.context.ServiceContext; +import org.fao.geonet.constants.Geonet; +import org.jdom.Element; + +//============================================================================= + +public class Editors implements Service +{ + //-------------------------------------------------------------------------- + //--- + //--- Init + //--- + //-------------------------------------------------------------------------- + + public void init(String appPath, ServiceConfig config) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + public Element exec(Element params, ServiceContext context) throws Exception + { + Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); + + UserSession us = context.getUserSession(); + List<Element> list = getUsers(context, us, dbms); + + Element result = new Element("root"); + + for (Element user : list) + { + user = (Element) user.clone(); + user.removeChild("password"); + user.setName("editor"); + + result.addContent(user); + } + + return result; + } + + //-------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //-------------------------------------------------------------------------- + + private List<Element> getUsers(ServiceContext context, UserSession us, Dbms dbms) throws SQLException + { + if (!us.isAuthenticated()) + return new ArrayList<Element>(); + + int id = Integer.parseInt(us.getUserId()); + + String query = "SELECT DISTINCT Users.id, name, surname FROM Users, Metadata "+ + "WHERE owner=Users.id AND profile='Editor'"; + + List list = dbms.select(query).getChildren(); + + if (us.getProfile().equals(Geonet.Profile.ADMINISTRATOR)) + return (List<Element>) list; + + //--- we have a user admin + + Set<String> hsMyGroups = getUserGroups(dbms, id); + + Set profileSet = context.getProfileManager().getProfilesSet(us.getProfile()); + + //--- now filter them + + ArrayList<Element> newList = new ArrayList<Element>(); + + for(Object o : list) + { + Element elRec = (Element) o; + + String userId = elRec.getChildText("id"); + String profile= elRec.getChildText("profile"); + + if (profileSet.contains(profile)) + if (hsMyGroups.containsAll(getUserGroups(dbms, Integer.parseInt(userId)))) + newList.add(elRec); + } + + //--- return result + + return newList; + } + + //-------------------------------------------------------------------------- + + private Set<String> getUserGroups(Dbms dbms, int id) throws SQLException + { + String query = "SELECT groupId AS id FROM UserGroups WHERE userId=?"; + + List list = dbms.select(query, id).getChildren(); + + HashSet<String> hs = new HashSet<String>(); + + for(int i=0; i<list.size(); i++) + { + Element el = (Element) list.get(i); + hs.add(el.getChildText("id")); + } + + return hs; + } +} + +//============================================================================= + Modified: trunk/web/geonetwork/WEB-INF/config-metadata.xml =================================================================== --- trunk/web/geonetwork/WEB-INF/config-metadata.xml 2007-08-10 10:26:43 UTC (rev 724) +++ trunk/web/geonetwork/WEB-INF/config-metadata.xml 2007-08-10 14:08:51 UTC (rev 725) @@ -314,6 +314,12 @@ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="xml.ownership.editors"> + <class name=".services.ownership.Editors"/> + </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="xml.ownership.groups"> <class name=".services.ownership.Groups"/> </service> Modified: trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml =================================================================== --- trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml 2007-08-10 10:26:43 UTC (rev 724) +++ trunk/web/geonetwork/loc/en/xml/transfer-ownership.xml 2007-08-10 14:08:51 UTC (rev 725) @@ -1,16 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <strings> - <sourceUser>Source user</sourceUser> - <targetUser>Target user</targetUser> + <sourceUser>Source editor</sourceUser> + <targetUser>Target editor</targetUser> <sourceGroup>Source group</sourceGroup> <targetGroup>Target group</targetGroup> <operation>Operation</operation> <cannotRetrieve>Cannot retrieve information from server</cannotRetrieve> <cannotTransfer>Cannot transfer ownership</cannotTransfer> - <noUser>No target user to transfer ownership to</noUser> + <noUser>No target editor to transfer ownership to</noUser> <transfer>Transfer</transfer> <result>Transferred {PRIV} privileges of {MD} metadata</result> + <noEditors>There are no editors with associated metadata</noEditors> </strings> Modified: trunk/web/geonetwork/scripts/ownership/model.js =================================================================== --- trunk/web/geonetwork/scripts/ownership/model.js 2007-08-10 10:26:43 UTC (rev 724) +++ trunk/web/geonetwork/scripts/ownership/model.js 2007-08-10 14:08:51 UTC (rev 725) @@ -11,7 +11,7 @@ //--- public methods - this.getUsers = getUsers; + this.getEditors = getEditors; this.getUserGroups = getUserGroups; this.transfer = transfer; @@ -21,11 +21,31 @@ //=== //===================================================================================== -function getUsers(callBack) +function getEditors(callBack) { - new InfoService(loader, 'users', callBack); + callBackF = callBack; + + ker.send('xml.ownership.editors', '<request/>', ker.wrap(this, getEditors_OK)); } +//------------------------------------------------------------------------------------- + +function getEditors_OK(xmlRes) +{ + if (xmlRes.nodeName == 'error') + ker.showError(loader.getText('cannotRetrieve'), xmlRes); + else + { + var data = []; + var list = xml.children(xmlRes); + + for (var i=0; i<list.length; i++) + data.push(xml.toObject(list[i])); + + callBackF(data); + } +} + //===================================================================================== function getUserGroups(userId, callBack) Modified: trunk/web/geonetwork/scripts/ownership/transfer-ownership.js =================================================================== --- trunk/web/geonetwork/scripts/ownership/transfer-ownership.js 2007-08-10 10:26:43 UTC (rev 724) +++ trunk/web/geonetwork/scripts/ownership/transfer-ownership.js 2007-08-10 14:08:51 UTC (rev 725) @@ -43,15 +43,17 @@ function init() { view.clearGroupList(); - model.getUsers(ker.wrap(this, init_OK)); + model.getEditors(ker.wrap(this, init_OK)); } //------------------------------------------------------------------------------------- function init_OK(data) { - for (var i=0; i<data.length; i++) - if (data[i].profile == 'Editor') + if (data.length == 0) + alert(loader.getText('noEditors')); + else + for (var i=0; i<data.length; i++) view.addSourceUser(data[i].id, data[i].surname +' '+ data[i].name); } Modified: trunk/web/geonetwork/xml/user-profiles.xml =================================================================== --- trunk/web/geonetwork/xml/user-profiles.xml 2007-08-10 10:26:43 UTC (rev 724) +++ trunk/web/geonetwork/xml/user-profiles.xml 2007-08-10 14:08:51 UTC (rev 725) @@ -22,7 +22,7 @@ <allow service="xml.category.update"/> <allow service="xml.operation.update"/> <allow service="xml.region.update"/> - + <!-- Utilities --> <allow service="util.import"/> <allow service="util.ping"/> @@ -60,9 +60,9 @@ <allow service="thesaurus.update"/> <allow service="thesaurus.upload"/> <allow service="thesaurus.download"/> - <allow service="thesaurus.delete"/> + <allow service="thesaurus.delete"/> <allow service="thesaurus.editelement"/> - <allow service="thesaurus.addelement"/> + <allow service="thesaurus.addelement"/> <allow service="thesaurus.deleteelement"/> <allow service="thesaurus.updateelement"/> <allow service="thesaurus.add"/> @@ -84,17 +84,18 @@ <!-- Transfer ownership services --> <allow service="transfer.ownership"/> + <allow service="xml.ownership.editors"/> <allow service="xml.ownership.groups"/> <allow service="xml.ownership.transfer"/> - + </profile> <!-- ====================================================================== --> <profile name="Reviewer" extends="Editor"/> - + <!-- ====================================================================== --> - + <profile name="Editor" extends="RegisteredUser"> <!-- Allow to see the list of groups the user is member of --> @@ -179,7 +180,7 @@ <allow service="main.search.embedded"/> <!-- ETj --> <allow service="main.present"/> <allow service="main.present.embedded"/> <!-- ETj --> - <allow service="metadata.show"/> + <allow service="metadata.show"/> <allow service="metadata.show.embedded"/> <!-- ETj --> <allow service="remote.show"/> @@ -231,14 +232,14 @@ <allow service="portal.latest.updated"/> <allow service="portal.featured"/> <allow service="portal.categories"/> - + <!-- Metadata export services --> <allow service="dc.xml"/> <allow service="fgdc.xml"/> <allow service="iso19115to19139.xml"/> <allow service="iso19139.xml"/> <allow service="iso_arccatalog8.xml"/> - + <!-- RSS services --> <allow service="rss.latest"/> <allow service="rss.search"/> @@ -255,18 +256,18 @@ <!-- Relation services --> <allow service="xml.relation.get"/> - + <!-- Metadata schema related --> <allow service="xml.schema.info"/> - + <!-- Thesaurus services --> <allow service="keywords.search"/> <allow service="keywords.sort"/> <allow service="keywords.select"/> <allow service="keywords.editsearch"/> - <allow service="keywords.getselected"/> + <allow service="keywords.getselected"/> <allow service="thesaurus.list"/> - <allow service="thesaurus.view"/><!-- FIXME : Check if needed --> + <allow service="thesaurus.view"/><!-- FIXME : Check if needed --> </profile> <!-- ====================================================================== --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-17 23:17:18
|
Revision: 728 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=728&view=rev Author: acarboni Date: 2007-08-17 16:17:19 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added WebDAV harvesting type Modified Paths: -------------- trunk/gast/setup/database.druid trunk/gast/setup/sql/create-db-mckoi.sql trunk/gast/setup/sql/create-db-mysql.sql trunk/gast/setup/sql/create-db-oracle.sql trunk/gast/setup/sql/create-db-postgres.sql trunk/src/org/fao/geonet/kernel/DataManager.java trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/WebDavHarvester.java trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/WebDavParams.java trunk/src/org/fao/geonet/lib/SourcesLib.java trunk/web/geonetwork/loc/en/xml/harvesting.xml trunk/web/geonetwork/scripts/harvesting/harvesting.js trunk/web/geonetwork/scripts/harvesting/webdav/model.js trunk/web/geonetwork/scripts/harvesting/webdav/view.js trunk/web/geonetwork/scripts/harvesting/webdav/webdav.js trunk/web/geonetwork/xsl/harvesting/harvesting.xsl trunk/web/geonetwork/xsl/harvesting/webdav/client-privil-row.xsl trunk/web/geonetwork/xsl/harvesting/webdav/client-result-tip.xsl trunk/web/geonetwork/xsl/harvesting/webdav/webdav.xsl trunk/web/geonetwork/xsl/xml/harvesting/webdav.xsl Added Paths: ----------- trunk/src/org/fao/geonet/kernel/harvest/harvester/UriMapper.java trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/Harvester.java trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/WebDavRemoteFile.java trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/WebDavRetriever.java trunk/web/geonetwork/WEB-INF/lib/jakarta-slide-webdavlib-2.1.jar Modified: trunk/gast/setup/database.druid =================================================================== --- trunk/gast/setup/database.druid 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/gast/setup/database.druid 2007-08-17 23:17:19 UTC (rev 728) @@ -2,8 +2,8 @@ <project version="2"> <attribs> - <attrib name="build">144</attrib> - <attrib name="serial">63756</attrib> + <attrib name="build">145</attrib> + <attrib name="serial">63913</attrib> </attribs> <database> <attribs> @@ -91,6 +91,17 @@ <elem>60</elem> <elem/> </row> + <row> + <elem>63909</elem> + <elem>Idx2</elem> + <elem>{table}NDX{cnt}</elem> + <elem>b</elem> + <elem>i</elem> + <elem>false</elem> + <elem>false</elem> + <elem>60</elem> + <elem/> + </row> </list> </fieldAttribs> <vars> @@ -139,6 +150,9 @@ </list> </sqlMapping> </oraSql> + <mckoiSql> + <output>/my/work/fao/geonetwork/cvs/geonetwork/trunk/gast/setup/sql/create-db-mckoi.sql</output> + </mckoiSql> <pgSql> <output>/my/work/fao/geonetwork/cvs/geonetwork/trunk/gast/setup/sql/create-db-postgres.sql</output> <sqlMapping type="l"> @@ -154,9 +168,6 @@ </list> </sqlMapping> </pgSql> - <mckoiSql> - <output>/my/work/fao/geonetwork/cvs/geonetwork/trunk/gast/setup/sql/create-db-mckoi.sql</output> - </mckoiSql> </SqlGenModule> </modsConfig> <modsUsage> @@ -895,6 +906,11 @@ <elem>Idx1</elem> <elem/> </row> + <row> + <elem>63909</elem> + <elem>Idx2</elem> + <elem/> + </row> </list> </idx> <postSql/> @@ -920,51 +936,73 @@ <elem>false</elem> <elem>false</elem> </row> + <row> + <elem>63909</elem> + <elem>Idx2</elem> + <elem/> + <elem>0</elem> + <elem>false</elem> + <elem>false</elem> + <elem>false</elem> + </row> </list> </idx> <ts>0</ts> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> + <row> + <elem>63909</elem> + <elem>Idx2</elem> + <elem/> + <elem>default</elem> + <elem/> + </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> + </row> + <row> + <elem>63909</elem> + <elem>Idx2</elem> <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -988,6 +1026,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">true</attrib> <attrib name="17">true</attrib> @@ -1011,6 +1050,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1034,6 +1074,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374">'n'</attrib> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1067,6 +1108,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374">'n'</attrib> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1090,6 +1132,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1113,6 +1156,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1136,6 +1180,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1159,8 +1204,9 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">true</attrib> <attrib name="54374"/> - <attrib name="61528">true</attrib> + <attrib name="61528">false</attrib> <attrib name="17">true</attrib> <attrib name="15">false</attrib> <attrib name="340">true</attrib> @@ -1182,6 +1228,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1205,6 +1252,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1228,6 +1276,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1251,6 +1300,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1274,6 +1324,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1294,6 +1345,30 @@ </attribs> <modsConfig/> </field> + <field> + <fieldAttribs> + <attribs> + <attrib name="63909">false</attrib> + <attrib name="54374"/> + <attrib name="61528">false</attrib> + <attrib name="17">false</attrib> + <attrib name="15">false</attrib> + <attrib name="340">false</attrib> + </attribs> + </fieldAttribs> + <attribs> + <attrib name="comment"/> + <attrib name="matchType">s</attrib> + <attrib name="refField">0</attrib> + <attrib name="name">harvestUri</attrib> + <attrib name="id">63759</attrib> + <attrib name="onDelete">n</attrib> + <attrib name="onUpdate">n</attrib> + <attrib name="refTable">0</attrib> + <attrib name="type">53372</attrib> + </attribs> + <modsConfig/> + </field> </table> <table> <vars> @@ -1360,47 +1435,48 @@ </list> </idx> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1424,6 +1500,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1512,47 +1589,48 @@ </idx> <ts>0</ts> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1576,6 +1654,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1599,6 +1678,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1685,47 +1765,48 @@ </list> </idx> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1749,6 +1830,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1843,47 +1925,48 @@ </idx> <ts>0</ts> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1907,6 +1990,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -1930,6 +2014,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1953,6 +2038,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -1976,6 +2062,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2062,47 +2149,48 @@ </list> </idx> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2126,6 +2214,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2149,6 +2238,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -2237,47 +2327,48 @@ </idx> <ts>0</ts> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2301,6 +2392,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2355,6 +2447,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2378,6 +2471,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -2464,47 +2558,48 @@ </list> </idx> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2528,6 +2623,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2551,6 +2647,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -2645,47 +2742,48 @@ </idx> <ts>0</ts> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2709,6 +2807,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2732,6 +2831,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -2755,6 +2855,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2841,47 +2942,48 @@ </list> </idx> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -2905,6 +3007,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -2991,47 +3094,48 @@ </list> </idx> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3055,6 +3159,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3083,6 +3188,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374">'y'</attrib> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3174,47 +3280,48 @@ </list> </idx> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3238,6 +3345,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3324,47 +3432,48 @@ </list> </idx> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3388,6 +3497,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3411,6 +3521,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3465,6 +3576,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3488,6 +3600,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3511,6 +3624,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3534,6 +3648,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3557,6 +3672,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3643,47 +3759,48 @@ </list> </idx> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3707,6 +3824,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3730,6 +3848,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3824,47 +3943,48 @@ </idx> <ts>0</ts> </oraSql> - <pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> - <mckoiSql> + </mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> + </pgSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3888,6 +4008,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3911,6 +4032,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -3934,6 +4056,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3957,6 +4080,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -3980,6 +4104,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -4003,6 +4128,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4026,6 +4152,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4049,6 +4176,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4072,6 +4200,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4095,6 +4224,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4118,6 +4248,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4141,6 +4272,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4235,47 +4367,48 @@ </idx> <ts>0</ts> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4299,6 +4432,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -4322,6 +4456,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374">'n'</attrib> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> @@ -4410,47 +4545,48 @@ </idx> <ts>0</ts> </oraSql> - <mckoiSql> + <pgSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> + <elem type="s">access</elem> + <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> + <elem>default</elem> + <elem/> </row> </list> </idx> - </mckoiSql> - <pgSql> + </pgSql> + <mckoiSql> <idx type="l"> <list> <header> <elem type="i">id</elem> <elem type="s">index</elem> <elem type="s">name</elem> - <elem type="s">access</elem> - <elem type="s">where</elem> </header> <row> <elem>61528</elem> <elem>Idx1</elem> <elem/> - <elem>default</elem> - <elem/> </row> </list> </idx> - </pgSql> + </mckoiSql> </SqlGenModule> </modsConfig> <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4474,6 +4610,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">false</attrib> @@ -4497,6 +4634,7 @@ <field> <fieldAttribs> <attribs> + <attrib name="63909">false</attrib> <attrib name="54374"/> <attrib name="61528">false</attrib> <attrib name="17">true</attrib> Modified: trunk/gast/setup/sql/create-db-mckoi.sql =================================================================== --- trunk/gast/setup/sql/create-db-mckoi.sql 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/gast/setup/sql/create-db-mckoi.sql 2007-08-17 23:17:19 UTC (rev 728) @@ -1,7 +1,7 @@ -- ====================================================================== -- === Sql Script for Database : Geonet -- === --- === Build : 143 +-- === Build : 145 -- ====================================================================== CREATE TABLE Relations @@ -232,6 +232,7 @@ harvestUuid varchar(250), owner int not null, groupOwner int, + harvestUri varchar(255), primary key(id), unique(uuid,source,harvestUuid), @@ -240,7 +241,8 @@ foreign key(groupOwner) references Groups(id) ); -CREATE INDEX MetadataNDX1 ON Metadata(uuid,source); +CREATE INDEX MetadataNDX1 ON Metadata(uuid); +CREATE INDEX MetadataNDX2 ON Metadata(source); -- ====================================================================== Modified: trunk/gast/setup/sql/create-db-mysql.sql =================================================================== --- trunk/gast/setup/sql/create-db-mysql.sql 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/gast/setup/sql/create-db-mysql.sql 2007-08-17 23:17:19 UTC (rev 728) @@ -1,7 +1,7 @@ -- ====================================================================== -- === Sql Script for Database : Geonet -- === --- === Build : 143 +-- === Build : 145 -- ====================================================================== CREATE TABLE Relations @@ -232,6 +232,7 @@ harvestUuid varchar(250), owner int not null, groupOwner int, + harvestUri varchar(255), primary key(id), unique(uuid,source,harvestUuid), @@ -240,7 +241,8 @@ foreign key(groupOwner) references Groups(id) ); -CREATE INDEX MetadataNDX1 ON Metadata(uuid,source); +CREATE INDEX MetadataNDX1 ON Metadata(uuid); +CREATE INDEX MetadataNDX2 ON Metadata(source); -- ====================================================================== Modified: trunk/gast/setup/sql/create-db-oracle.sql =================================================================== --- trunk/gast/setup/sql/create-db-oracle.sql 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/gast/setup/sql/create-db-oracle.sql 2007-08-17 23:17:19 UTC (rev 728) @@ -1,7 +1,7 @@ REM ====================================================================== REM === Sql Script for Database : Geonet REM === -REM === Build : 143 +REM === Build : 145 REM ====================================================================== CREATE TABLE Relations @@ -208,13 +208,15 @@ harvestUuid varchar(250), owner int not null, groupOwner int, + harvestUri varchar(255), primary key(id), unique(uuid,source,harvestUuid), foreign key(owner) references Users(id), foreign key(groupOwner) references Groups(id) ); -CREATE INDEX MetadataNDX1 ON Metadata(uuid,source); +CREATE INDEX MetadataNDX1 ON Metadata(uuid); +CREATE INDEX MetadataNDX2 ON Metadata(source); REM ====================================================================== Modified: trunk/gast/setup/sql/create-db-postgres.sql =================================================================== --- trunk/gast/setup/sql/create-db-postgres.sql 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/gast/setup/sql/create-db-postgres.sql 2007-08-17 23:17:19 UTC (rev 728) @@ -1,7 +1,7 @@ -- ====================================================================== -- === Sql Script for Database : Geonet -- === --- === Build : 143 +-- === Build : 145 -- ====================================================================== CREATE TABLE Relations @@ -232,6 +232,7 @@ harvestUuid varchar(250), owner int not null, groupOwner int, + harvestUri varchar(255), primary key(id), unique(uuid,source,harvestUuid), @@ -240,7 +241,8 @@ foreign key(groupOwner) references Groups(id) ); -CREATE INDEX MetadataNDX1 ON Metadata(uuid,source); +CREATE INDEX MetadataNDX1 ON Metadata(uuid); +CREATE INDEX MetadataNDX2 ON Metadata(source); -- ====================================================================== Modified: trunk/src/org/fao/geonet/kernel/DataManager.java =================================================================== --- trunk/src/org/fao/geonet/kernel/DataManager.java 2007-08-17 23:15:02 UTC (rev 727) +++ trunk/src/org/fao/geonet/kernel/DataManager.java 2007-08-17 23:17:19 UTC (rev 728) @@ -440,6 +440,17 @@ indexMetadata(dbms, Integer.toString(id)); } + //-------------------------------------------------------------------------- + + public void setHarvested(Dbms dbms, int id, String harvestUuid, String harvestUri) throws Exception + { + String value = (harvestUuid != null) ? "y" : "n"; + String query = "UPDATE Metadata SET isHarvested=?, harvestUuid=?, harvestUri=? WHERE id=?"; + + dbms.execute(query, value, harvestUuid, harvestUri, id); + indexMetadata(dbms, Integer.toString(id)); + } + //--------------------------------------------------------------------------- public String getSiteURL() @@ -971,14 +982,14 @@ if (attr != null) { // The following work-around decodes any attribute name that has a COLON in it // The : is replaced by the word COLON in the xslt so that it can be processed -// by the XML Serializer when an update is submitted - the only situation +// by the XML Serializer when an update is submitted - the only situation // where this is known to occur is in the gml schema (eg. gml:id) - a better // solution may be required Integer indexColon = attr.indexOf("COLON"); - if (indexColon != -1) { + if (indexColon != -1) { String prefix = attr.substring(0,indexColon); String localname = attr.substring(indexColon + 5); - String namespace = editLib.getNamespace(prefix+":"+localname,md); + String namespace = editLib.getNamespace(prefix+":"+localname,md); Namespace attrNS = Namespace.getNamespace(prefix,namespace); if (el.getAttribute(localname,attrNS) != null) { el.setAttribute(new Attribute(localname,val,attrNS)); Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/UriMapper.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/UriMapper.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/UriMapper.java 2007-08-17 23:17:19 UTC (rev 728) @@ -0,0 +1,85 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester; + +import java.util.HashMap; +import java.util.List; +import jeeves.resources.dbms.Dbms; +import org.jdom.Element; + +//============================================================================= + +/** Create a mapping (remote URI) -> (local ID / change date). Retrieves all + * metadata of a given harvest uuid and puts them into an hashmap. + */ + +public class UriMapper +{ + private HashMap<String, String> hmUriDate = new HashMap<String, String>(); + private HashMap<String, String> hmUriId = new HashMap<String, String>(); + + //-------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //-------------------------------------------------------------------------- + + public UriMapper(Dbms dbms, String harvestUuid) throws Exception + { + String query = "SELECT id, harvestUri, changeDate FROM Metadata WHERE harvestUuid=?"; + + List idsList = dbms.select(query, harvestUuid).getChildren(); + + for (int i=0; i<idsList.size(); i++) + { + Element record = (Element) idsList.get(i); + + String id = record.getChildText("id"); + String uri = record.getChildText("harvesturi"); + String date = record.getChildText("changedate"); + + hmUriDate.put(uri, date); + hmUriId .put(uri, id); + } + } + + //-------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //-------------------------------------------------------------------------- + + public String getChangeDate(String uri) { return hmUriDate.get(uri); } + + //-------------------------------------------------------------------------- + + public String getID(String uri) { return hmUriId.get(uri); } + + //-------------------------------------------------------------------------- + + public Iterable<String> getUris() { return hmUriDate.keySet(); } +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/Harvester.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/Harvester.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/webdav/Harvester.java 2007-08-17 23:17:19 UTC (rev 728) @@ -0,0 +1,379 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.webdav; + +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import jeeves.interfaces.Logger; +import jeeves.resources.dbms.Dbms; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Xml; +import org.fao.geonet.GeonetContext; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.DataManager; +import org.fao.geonet.kernel.harvest.harvester.CategoryMapper; +import org.fao.geonet.kernel.harvest.harvester.GroupMapper; +import org.fao.geonet.kernel.harvest.harvester.Privileges; +import org.fao.geonet.kernel.harvest.harvester.UriMapper; +import org.jdom.Element; +import org.jdom.JDOMException; + +//============================================================================= + +class Harvester +{ + //-------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //-------------------------------------------------------------------------- + + public Harvester(Logger log, ServiceContext context, Dbms dbms, WebDavParams params) + { + this.log = log; + this.context= context; + this.dbms = dbms; + this.params = params; + + result = new WebDavResult(); + + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + dataMan = gc.getDataManager(); + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public WebDavResult harvest() throws Exception + { + log.info("Retrieving remote metadata information for : "+ params.name); + + RemoteRetriever rr = new WebDavRetriever(); + rr.init(log, context, params); + List<RemoteFile> files = rr.retrieve(); + + log.info("Remote files found : "+ files.size()); + + align(files); + rr.destroy(); + + return result; + } + + //--------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //--------------------------------------------------------------------------- + + private void align(List<RemoteFile> files) throws Exception + { + log.info("Start of alignment for : "+ params.name); + + //----------------------------------------------------------------------- + //--- retrieve all local categories and groups + //--- retrieve harvested uuids for given harvesting node + + localCateg = new CategoryMapper(dbms); + localGroups= new GroupMapper(dbms); + localUris = new UriMapper(dbms, params.uuid); + dbms.commit(); + + //----------------------------------------------------------------------- + //--- remove old metadata + + for (String uri : localUris.getUris()) + if (!exists(files, uri)) + { + String id = localUris.getID(uri); + + log.debug(" - Removing old metadata with local id:"+ id); + dataMan.deleteMetadata(dbms, id); + dbms.commit(); + result.locallyRemoved++; + } + + //----------------------------------------------------------------------- + //--- insert/update new metadata + + for(RemoteFile rf : files) + { + result.total++; + + String id = localUris.getID(rf.getPath()); + + if (id == null) addMetadata(rf); + else updateMetadata(rf, id); + } + + log.info("End of alignment for : "+ params.name); + } + + //-------------------------------------------------------------------------- + /** Return true if the uri is present in the remote folder */ + + private boolean exists(List<RemoteFile> files, String uri) + { + for(RemoteFile rf : files) + if (uri.equals(rf.getPath())) + return true; + + return false; + } + + //-------------------------------------------------------------------------- + //--- + //--- Private methods : addMetadata + //--- + //-------------------------------------------------------------------------- + + private void addMetadata(RemoteFile rf) throws Exception + { + Element md = retrieveMetadata(rf); + + if (md == null) + return; + + //--- schema handled check already done + + String schema = dataMan.autodetectSchema(md); + String uuid = UUID.randomUUID().toString(); + + log.debug(" - Setting uuid for metadata with remote path : "+ rf.getPath()); + + //--- set uuid inside metadata and get new xml + md = dataMan.setUUID(schema, uuid, md); + + log.debug(" - Adding metadata with remote path : "+ rf.getPath()); + + String id = dataMan.insertMetadataExt(dbms, schema, md, context.getSerialFactory(), + params.uuid, rf.getChangeDate(), rf.getChangeDate(), uuid, 1, null); + + int iId = Integer.parseInt(id); + + dataMan.setTemplate(dbms, iId, "n", null); + dataMan.setHarvested(dbms, iId, params.uuid, rf.getPath()); + + addPrivileges(id); + addCategories(id); + + dbms.commit(); + dataMan.indexMetadata(dbms, id); + result.added++; + } + + //-------------------------------------------------------------------------- + + private Element retrieveMetadata(RemoteFile rf) + { + try + { + log.debug("Getting remote file : "+ rf.getPath()); + ... [truncated message content] |
From: <aca...@us...> - 2007-08-18 13:30:58
|
Revision: 732 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=732&view=rev Author: acarboni Date: 2007-08-18 06:30:59 -0700 (Sat, 18 Aug 2007) Log Message: ----------- Changed radio button to dropdown list to be compatible with IE Modified Paths: -------------- trunk/docs/changes.txt trunk/web/geonetwork/scripts/harvesting/geonet/view.js trunk/web/geonetwork/xsl/harvesting/geonet/client-policy-row.xsl trunk/web/geonetwork/xsl/harvesting/geonet/geonetwork.xsl Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-08-17 23:21:15 UTC (rev 731) +++ trunk/docs/changes.txt 2007-08-18 13:30:59 UTC (rev 732) @@ -27,6 +27,9 @@ - Fixed bug in CSW harvesting: the privilege rows were pointing to webdav code +- Harvesting of type=geonetwork: changed radio buttons to dropdown list due to + usual problems with IE + ================================================================================ === === GeoNetwork 2.1.0 beta5 : List of changes Modified: trunk/web/geonetwork/scripts/harvesting/geonet/view.js =================================================================== --- trunk/web/geonetwork/scripts/harvesting/geonet/view.js 2007-08-17 23:21:15 UTC (rev 731) +++ trunk/web/geonetwork/scripts/harvesting/geonet/view.js 2007-08-18 13:30:59 UTC (rev 732) @@ -327,14 +327,10 @@ //--- format is : gn.group.{@name} var name = id.substring(9); - var list = rowElem.getElementsByTagName('INPUT'); + var list = rowElem.getElementsByTagName('SELECT'); - var policy = 'dontCopy'; + var policy = $F(list[0]); - for (var j=0; j<list.length; j++) - if (list[j].checked) - policy = list[j].value; - if (policy != 'dontCopy') groupData.push( { Modified: trunk/web/geonetwork/xsl/harvesting/geonet/client-policy-row.xsl =================================================================== --- trunk/web/geonetwork/xsl/harvesting/geonet/client-policy-row.xsl 2007-08-17 23:21:15 UTC (rev 731) +++ trunk/web/geonetwork/xsl/harvesting/geonet/client-policy-row.xsl 2007-08-18 13:30:59 UTC (rev 732) @@ -16,53 +16,47 @@ <td class="padded"><xsl:value-of select="@name"/></td> <td class="padded"> - <form> + <select id="gn.copyPolicy" class="content" size="1"> <!-- copy --> - <div> - <input name="gn.copyPolicy" type="radio" value="copy"> + <option value="copy"> <xsl:if test="@policy = 'copy'"> - <xsl:attribute name="checked"/> + <xsl:attribute name="selected">on</xsl:attribute> </xsl:if> - </input> <xsl:value-of select="/root/strings/policy/copy"/> - </div> + </option> <!-- copy to intranet or create and copy --> - <div> <xsl:choose> <xsl:when test="@name = 'all'"> - <input name="gn.copyPolicy" type="radio" value="copyToIntranet"> + <option value="copyToIntranet"> <xsl:if test="@policy = 'copyToIntranet'"> - <xsl:attribute name="checked"/> + <xsl:attribute name="selected">on</xsl:attribute> </xsl:if> - </input> - <xsl:value-of select="/root/strings/policy/copyToIntranet"/> + <xsl:value-of select="/root/strings/policy/copyToIntranet"/> + </option> </xsl:when> <xsl:otherwise> - <input name="gn.copyPolicy" type="radio" value="createAndCopy"> + <option value="createAndCopy"> <xsl:if test="@policy = 'createAndCopy'"> - <xsl:attribute name="checked"/> + <xsl:attribute name="selected">on</xsl:attribute> </xsl:if> - </input> - <xsl:value-of select="/root/strings/policy/createAndCopy"/> + <xsl:value-of select="/root/strings/policy/createAndCopy"/> + </option> </xsl:otherwise> </xsl:choose> - </div> <!-- don't copy --> - <div> - <input name="gn.copyPolicy" type="radio" value="dontCopy"> - <xsl:if test="@policy = 'dontCopy'"> - <xsl:attribute name="checked"/> - </xsl:if> - </input> + <option value="dontCopy"> + <xsl:if test="@policy = 'dontCopy'"> + <xsl:attribute name="selected">on</xsl:attribute> + </xsl:if> <xsl:value-of select="/root/strings/policy/dontCopy"/> - </div> - </form> + </option> + </select> </td> </tr> Modified: trunk/web/geonetwork/xsl/harvesting/geonet/geonetwork.xsl =================================================================== --- trunk/web/geonetwork/xsl/harvesting/geonet/geonetwork.xsl 2007-08-17 23:21:15 UTC (rev 731) +++ trunk/web/geonetwork/xsl/harvesting/geonet/geonetwork.xsl 2007-08-18 13:30:59 UTC (rev 732) @@ -119,8 +119,8 @@ <table id="gn.groups"> <tr class="policyGroup"> - <th><xsl:value-of select="/root/gui/harvesting/remoteGroup"/></th> - <th><xsl:value-of select="/root/gui/harvesting/copyPolicy"/></th> + <th style="width:150px;"><b><xsl:value-of select="/root/gui/harvesting/remoteGroup"/></b></th> + <th><b><xsl:value-of select="/root/gui/harvesting/copyPolicy"/></b></th> </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-19 15:01:55
|
Revision: 735 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=735&view=rev Author: acarboni Date: 2007-08-19 08:01:57 -0700 (Sun, 19 Aug 2007) Log Message: ----------- Updated version Modified Paths: -------------- trunk/docs/readme.html trunk/installer/installer-config.xml trunk/web/geonetwork/WEB-INF/server.prop Modified: trunk/docs/readme.html =================================================================== --- trunk/docs/readme.html 2007-08-19 14:56:17 UTC (rev 734) +++ trunk/docs/readme.html 2007-08-19 15:01:57 UTC (rev 735) @@ -9,7 +9,7 @@ </style></head> <body> - <div align="right"><span class="style1">GeoNetwork opensource V2.1.0 beta5 Date: 25-07-2007</span></div> + <div align="right"><span class="style1">GeoNetwork opensource V2.1.0 RC Date: 2007-08-19</span></div> <h1>GeoNetwork - Getting started</h1> <h2>Running the application</h2> Modified: trunk/installer/installer-config.xml =================================================================== --- trunk/installer/installer-config.xml 2007-08-19 14:56:17 UTC (rev 734) +++ trunk/installer/installer-config.xml 2007-08-19 15:01:57 UTC (rev 735) @@ -6,7 +6,7 @@ <info> <appname>geonetwork</appname> - <appversion>2.1.0 beta5</appversion> + <appversion>2.1.0 RC</appversion> <authors> <author name="FAO GeoNetwork Team" email="Geo...@fa..."/> <author name="VAM WFP" email="va...@wf..."/> Modified: trunk/web/geonetwork/WEB-INF/server.prop =================================================================== --- trunk/web/geonetwork/WEB-INF/server.prop 2007-08-19 14:56:17 UTC (rev 734) +++ trunk/web/geonetwork/WEB-INF/server.prop 2007-08-19 15:01:57 UTC (rev 735) @@ -1,8 +1,8 @@ # geonetwork version ### this is used to build the jar filename -release = 2.1.0-beta5 +release = 2.1.0-rc ### these are used by both gast and geonetwork at runtime version = 2.1.0 -subVersion = beta5 +subVersion = rc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-08-21 12:26:02
|
Revision: 746 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=746&view=rev Author: e_tajariol Date: 2007-08-21 05:25:56 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Add: maps and related info can be exported as PDF. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java trunk/web/intermap/WEB-INF/config.xml trunk/web/intermap/intermap-embedded.css trunk/web/intermap/scripts/im_extras.js trunk/web/intermap/xml/user-profiles.xml Added Paths: ----------- trunk/src/org/wfp/vam/intermap/services/export/ trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java trunk/web/intermap/WEB-INF/lib/itext-2.0.4.jar trunk/web/intermap/xsl/im_pdf_form.xsl Modified: trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-08-21 12:09:41 UTC (rev 745) +++ trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-08-21 12:25:56 UTC (rev 746) @@ -19,6 +19,7 @@ import org.jdom.Element; import org.wfp.vam.intermap.http.ConcurrentHTTPTransactionHandler; import org.wfp.vam.intermap.http.cache.HttpGetFileCache; +import org.wfp.vam.intermap.kernel.GlobalTempFiles; import org.wfp.vam.intermap.kernel.TempFiles; import org.wfp.vam.intermap.kernel.map.images.ImageMerger; import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; @@ -212,6 +213,26 @@ return elServices; } +// public Iterable<Layer> getLayers() +// { +// return new Iterable<Layer>() +// { +// public Iterator<Layer> iterator() +// { +// return new Iterator<Layer>() +// { +// private int i = 0; +// private int last = vRank.size(); +// +// public boolean hasNext() { return i<last; } +// public Layer next() { return _layers.get(vRank.get(i++)); } +// public void remove() { throw new UnsupportedOperationException();} +// }; +// } +// }; +// } + + /** Returns an Element containing the transparency value for each service */ public Element getStructTransparencies() { Element elTransparency = new Element("transparency"); @@ -243,6 +264,9 @@ public int getLayerTransparency(int id) { return _layers.get(id).getIntTransparency(); } + public int getLayerTransparencyRanked(int id) { + return _layers.get(vRank.get(id)).getIntTransparency(); + } /** Sets the transparency value for a given service */ public void setTransparency(int id, float transparency) throws Exception { @@ -346,7 +370,10 @@ /** Returns the MapService element with the given id*/ public MapService getService(int id) { return _layers.get(id).getService(); } + public MapService getServiceRanked(int id) { return _layers.get(vRank.get(id)).getService(); } // public MapService getService(int id) { return (MapService)htServices.get(new Integer(id)); } +// public boolean isVisible(int id) { return _layers.get(id).isVisible(); } + public boolean isVisibleRanked(int id) { return _layers.get(vRank.get(id)).isVisible(); } /** Returns an element containing informations about the expanded or collapsed * services @@ -571,7 +598,7 @@ if (files.size() > 1) { // Merge the images - File output = TempFiles.getFile(); + File output = GlobalTempFiles.getInstance().getFile(); String path = output.getPath(); // System.out.println("vTransparency" + vTransparency); // DEBUG ImageMerger.mergeAndSave(files, vTransparency, path, ImageMerger.GIF); @@ -583,7 +610,7 @@ else if (files.size() == 1) { // System.out.println("files.get(0) = " + files.get(0)); // DEBUG File f = new File( files.get(0) ); - File out = TempFiles.getFile(); + File out = GlobalTempFiles.getInstance().getFile(); // System.out.println("out.getPath() = " + out.getPath()); // DEBUG BufferedInputStream is = new BufferedInputStream(new FileInputStream(f)); @@ -609,8 +636,16 @@ return imageName; } - public String getImageName() { return imageName; } + public String getImageName() + { + return imageName; + } + public File getImageLocalPath() + { + return GlobalTempFiles.getInstance().getDir(); + } + // public String getImagePath() { return imagePath; } public String getDegScale() { @@ -734,7 +769,7 @@ try { c = new HttpClient(stUrl); - File tf = TempFiles.getFile(); + File tf = GlobalTempFiles.getInstance().getFile(); c.getFile(tf); path = tf.getPath(); } Added: trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java 2007-08-21 12:25:56 UTC (rev 746) @@ -0,0 +1,242 @@ + + +package org.wfp.vam.intermap.services.export; + +import com.lowagie.text.*; + +import com.lowagie.text.pdf.PdfPCell; +import com.lowagie.text.pdf.PdfPTable; +import com.lowagie.text.pdf.PdfWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.util.HashMap; +import java.util.Map; +import jeeves.interfaces.Service; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; +import org.wfp.vam.intermap.kernel.GlobalTempFiles; +import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; +import org.wfp.vam.intermap.services.map.MapUtil; +import org.wfp.vam.intermap.util.Util; + +public class ExportPDF implements Service +{ + public void init(String appPath, ServiceConfig config) throws Exception {} + + public Element exec(Element params, ServiceContext context) throws Exception + { + MapMerger mm = MapUtil.getMapMerger(context); + + Rectangle pagesize = parsePagesize(params.getChildText("pagesize")); + boolean isLandscape = isLandscape(params.getChildText("orientation")); + if(isLandscape) + pagesize = pagesize.rotate(); + + BoundingBox bb = Util.parseBoundingBox(params); // search bb in params + if( bb != null) + mm.setBoundingBox(bb); + + String imagename = mm.merge(1160, 870); + File imagepath = mm.getImageLocalPath(); + + Document document = new Document(pagesize); + document.addCreator("Geonetwork Intermap"); + document.addTitle("Geonetwork Map"); + document.addCreationDate(); + + File pdfFile = GlobalTempFiles.getInstance().getFile(".pdf"); + PdfWriter pw = PdfWriter.getInstance(document, new FileOutputStream(pdfFile)); + document.open(); + + // Add image + Image image = Image.getInstance(imagepath.getAbsolutePath()+File.separator+imagename); + image.scaleToFit(500,400); + image.setAlignment(Image.MIDDLE); + document.add(image); + + if(params.getChildText("layerlist") != null) // the user wants the layer list + { + document.add(new Paragraph("Layers list:")); + List llist = new List(true, 20); + + for (int i = 0; i < mm.size(); i++) + { + ListItem litem = new ListItem(); + + // Add layer name + String servicename = mm.getServiceRanked(i).getName(); + Chunk name = new Chunk(servicename); + if( ! mm.isVisibleRanked(i) ) + { + System.out.println("Service " + servicename + " is hidden"); + Font font = new Font(); + font.setStyle(Font.STRIKETHRU); + name.setFont(font); + } + litem.add(name); + + if(params.getChildText("details") != null) // the user wants details + { + // Add transparency info + Font font = new Font(); + font.setSize(Font.DEFAULTSIZE*0.8f); + font.setStyle(Font.ITALIC); + int trasp = mm.getLayerTransparencyRanked(i); + if(trasp != 100) + { + Chunk transp = new Chunk( " (" + mm.getLayerTransparencyRanked(i)+"%)", font); + litem.add(transp); + } + } + + llist.add(litem); + } + + document.add(llist); + } + + if(params.getChildText("boundingbox") != null) // the user wants the bbox + { + // Be careful: the requested bbox may be reaspected to respect image dimensions + // Let's say we'll print the reaspected bbox + + PdfPTable t = getBBTable(mm.getBoundingBox()); + t.setSpacingBefore(30); + document.add(t); + } + + document.close(); + + return new Element("response") + .addContent(new Element("pdf") + .addContent(new Element("url").setText(MapUtil.getTempUrl() + "/" + pdfFile.getName()))); + } + + private PdfPTable getBBTable(BoundingBox bb) + { + PdfPTable t = new PdfPTable(3); + + PdfPCell empty = new PdfPCell(new Paragraph("")); + empty.setBorder(0); + + PdfPCell n = new PdfPCell(new Paragraph("N: " + bb.getNorth())); + n.setVerticalAlignment(Cell.ALIGN_MIDDLE); + n.setHorizontalAlignment(Cell.ALIGN_CENTER); + PdfPCell e = new PdfPCell(new Paragraph("E: " + bb.getEast())); + e.setVerticalAlignment(Cell.ALIGN_MIDDLE); + e.setHorizontalAlignment(Cell.ALIGN_LEFT); + PdfPCell w = new PdfPCell(new Paragraph("W: " + bb.getWest())); + w.setVerticalAlignment(Cell.ALIGN_MIDDLE); + w.setHorizontalAlignment(Cell.ALIGN_RIGHT); + PdfPCell s = new PdfPCell(new Paragraph("S: " + bb.getSouth())); + s.setVerticalAlignment(Cell.ALIGN_MIDDLE); + s.setHorizontalAlignment(Cell.ALIGN_CENTER); + + t.addCell(new PdfPCell(empty)); + t.addCell(n); + t.addCell(new PdfPCell(empty)); + + t.addCell(w); + t.addCell(new PdfPCell(empty)); + t.addCell(e); + + t.addCell(new PdfPCell(empty)); + t.addCell(s); + t.addCell(new PdfPCell(empty)); + + return t; + } + + private boolean isLandscape(String o) + { + if(o.equalsIgnoreCase("landscape")) + return true; + else if(o.equalsIgnoreCase("portrait")) + return false; + else + return false; // Set the default value to your liking + } + + private static final Map<String, Rectangle> PAGESIZE = new HashMap<String, Rectangle>(); + static + { + PAGESIZE.put("a4", PageSize.A4); + PAGESIZE.put("a3", PageSize.A3); + PAGESIZE.put("letter", PageSize.LETTER); + PAGESIZE.put("legal", PageSize.LEGAL); + } + + private Rectangle parsePagesize(String ps) + { + Rectangle ret = PAGESIZE.get(ps); + if(ret == null) + ret = PageSize.A4; // set the default pagesize as you like + + return ret; + } + +// public static void main(String[] args) throws DocumentException, FileNotFoundException, IOException, BadElementException +// { +// Document document = new Document(PageSize.A4); +// +// PdfWriter pw = PdfWriter.getInstance(document, new FileOutputStream("/tmp/my.pdf")); +// +// document.addCreator("Geonetwork Intermap"); +// document.addTitle("Geonetwork Map"); +// document.addCreationDate(); +// +// document.open(); +// document.add(new Paragraph("This is a paragraph")); +// Image image = Image.getInstance(new URL("file:///tmp/1160x870.gif")); +// System.out.println("XDPI="+image.getDpiX()); +// System.out.println("YDPI="+image.getDpiY()); +// +// image.scaleToFit(500,400); +// image.setAlignment(Image.MIDDLE); +// System.out.println("XDPI="+image.getDpiX()); +// System.out.println("YDPI="+image.getDpiY()); +// document.add(image); +// +// PdfPTable t = new PdfPTable(3); +// +// PdfPCell empty = new PdfPCell(new Paragraph("")); +// empty.setBorder(0); +// +// PdfPCell n = new PdfPCell(new Paragraph("N: 123.456")); +// n.setVerticalAlignment(Cell.ALIGN_MIDDLE); +// n.setHorizontalAlignment(Cell.ALIGN_CENTER); +//// n.set +// PdfPCell e = new PdfPCell(new Paragraph("E: 23.56")); +// e.setVerticalAlignment(Cell.ALIGN_MIDDLE); +// e.setHorizontalAlignment(Cell.ALIGN_LEFT); +// PdfPCell w = new PdfPCell(new Paragraph("W: -23.56")); +// w.setVerticalAlignment(Cell.ALIGN_MIDDLE); +// w.setHorizontalAlignment(Cell.ALIGN_RIGHT); +// PdfPCell s = new PdfPCell(new Paragraph("S: 123.456")); +// s.setVerticalAlignment(Cell.ALIGN_MIDDLE); +// s.setHorizontalAlignment(Cell.ALIGN_CENTER); +// +// +// t.addCell(new PdfPCell(empty)); +// t.addCell(n); +// t.addCell(new PdfPCell(empty)); +// +// t.addCell(w); +// t.addCell(new PdfPCell(empty)); +// t.addCell(e); +// +// t.addCell(new PdfPCell(empty)); +// t.addCell(s); +// t.addCell(new PdfPCell(empty)); +// +// document.add(t); +// +// document.close(); +// +// } + +} + + Modified: trunk/web/intermap/WEB-INF/config.xml =================================================================== --- trunk/web/intermap/WEB-INF/config.xml 2007-08-21 12:09:41 UTC (rev 745) +++ trunk/web/intermap/WEB-INF/config.xml 2007-08-21 12:25:56 UTC (rev 746) @@ -498,8 +498,22 @@ <output forward="map.update" /> </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="static.form.pdf"> + <output sheet="im_pdf_form.xsl" contentType="text/html; charset=UTF-8" /> + </service> + + <service name="create.pdf"> + <class name=".services.export.ExportPDF"/> + </service> + + + </services> + + <!-- ====================================================================== --> Added: trunk/web/intermap/WEB-INF/lib/itext-2.0.4.jar =================================================================== (Binary files differ) Property changes on: trunk/web/intermap/WEB-INF/lib/itext-2.0.4.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/web/intermap/intermap-embedded.css =================================================================== --- trunk/web/intermap/intermap-embedded.css 2007-08-21 12:09:41 UTC (rev 745) +++ trunk/web/intermap/intermap-embedded.css 2007-08-21 12:25:56 UTC (rev 746) @@ -813,7 +813,7 @@ } -#im_serverList_list button { +#im_whiteboard button { border:1px solid #266397; color:#064377; cursor:pointer; Modified: trunk/web/intermap/scripts/im_extras.js =================================================================== --- trunk/web/intermap/scripts/im_extras.js 2007-08-21 12:09:41 UTC (rev 745) +++ trunk/web/intermap/scripts/im_extras.js 2007-08-21 12:25:56 UTC (rev 746) @@ -1,10 +1,10 @@ -/*\xB0******************************************************** +/******************************************************************** * im_extras.js * * This file contains functions related to the intermap extra features * ie the ones the user can call via the buttons below the bigger map. * -*\xB0********************************************************/ +********************************************************************/ /******************************************************************** *** LAYERS @@ -71,22 +71,23 @@ ); // add a textbox to enter a server directly - var li = document.createElement('li'); - li.innerHTML = 'Other WMS server'; // FIXME i18n - ul.appendChild(li); - - var input = document.createElement('input'); - input.id= "im_wmsservername"; - input.className = 'content'; - input.setAttribute("type", "text"); - input.setAttribute("size", "40"); - li.appendChild(input); - - var button = document.createElement('button'); - button.innerHTML = "Connect"; // FIXME i18n - li.appendChild(button); - - Event.observe(button, "click", function() { im_mapServerURL($('im_wmsservername').value);}); + var li = document.createElement('li'); + li.innerHTML = 'Other WMS server'; // FIXME i18n + ul.appendChild(li); + + var input = document.createElement('input'); + input.id= "im_wmsservername"; + input.className = 'content'; + input.setAttribute("type", "text"); + input.setAttribute("size", "40"); + li.appendChild(input); + + // connect button + var button = document.createElement('button'); + button.innerHTML = "Connect"; // FIXME i18n + div.appendChild(button); + + Event.observe(button, "click", function() { im_mapServerURL($('im_wmsservername').value);}); } /* @@ -264,35 +265,91 @@ /* ## Called by the bottom toolbar */ -function im_createPDF() +function im_openPDFform() { - clearNode('im_whiteboard'); + // setup WB + clearNode('im_whiteboard'); + var WB = $('im_whiteboard'); - var div = document.createElement('div'); - div.id = "im_createPDF"; - div.className = 'im_wbcontent'; - $('im_whiteboard').appendChild(div); - var wbtitle = im_createWBTitle("Export this map as PDF"); //FIXME i18n - div.appendChild(wbtitle); + WB.appendChild(wbtitle); var closer = im_getWBCloser(); - div.appendChild(closer); + WB.appendChild(closer); Event.observe(closer, 'click', im_closeWhiteBoard); - var h1 = document.createElement('h1'); - h1.innerHTML = "TODO" ; //FIXME i18n - div.appendChild(h1); + var div = document.createElement('div'); // main box + div.id = "im_createPDF"; + div.className = 'im_wbcontent'; + WB.appendChild(div); + + var myAjax = new Ajax.Updater ( + 'im_createPDF', + '/intermap/srv/en/static.form.pdf', + { + method: 'get', + onFailure: im_load_error + } + ); } +function im_requestPDF() +{ + var orient = $('pdf_orientation').value; + var psize = $('pdf_pagesize').value; + var bllist = $('pdf_layerlist').checked; + var bdetails = $('pdf_details').checked; + var bbbox = $('pdf_boundingbox').checked; + + var pars = "orientation="+orient+ + "&pagesize="+psize+ + "&"+im_bm_getURLbbox(); + if(bllist) + pars += "&layerlist=on"; + + if(bdetails) + pars += "&details=on"; + + if(bbbox) + pars += "&boundingbox=on"; + + $('im_requestingpdf').show(); + $('im_requestpdf').hide(); + $('im_builtpdf').hide(); + + var myAjax = new Ajax.Request ( + '/intermap/srv/en/create.pdf', + { + method: 'get', + parameters: pars, + onSuccess: im_openPDF, + onFailure: im_load_error + } + ); + +} + +function im_openPDF(req) +{ + var url = req.responseXML.documentElement.getElementsByTagName('url')[0].firstChild.nodeValue; +/* var url = req.responseXML.documentElement.getElementsByTagName('response')[0].getElementsByTagName('pdf')[0].getElementsByTagName('url')[0].textContent;*/ + + window.open(url); + + $('im_requestpdf').show(); + $('im_requestingpdf').hide(); + $('im_builtpdf').show(); + +} + /******************************************************************** *** Export image ********************************************************************/ /* ## Called by the bottom toolbar */ -function im_createPic() +function im_openPictureForm() { clearNode('im_whiteboard'); @@ -317,6 +374,7 @@ *** SUB TOOLBAR UTILITIES ********************************************************************/ + function im_createWBTitle(title) { var div = Builder.node('div', {id: "im_wbtitle"}); @@ -350,6 +408,3 @@ // Effect.BlindUp('im_whiteboard'); clearNode('im_whiteboard'); } - - - Modified: trunk/web/intermap/xml/user-profiles.xml =================================================================== --- trunk/web/intermap/xml/user-profiles.xml 2007-08-21 12:09:41 UTC (rev 745) +++ trunk/web/intermap/xml/user-profiles.xml 2007-08-21 12:25:56 UTC (rev 746) @@ -6,8 +6,11 @@ <allow service="map.getMain"/> <allow service="map.getMain.embedded"/> - <allow service="minimap.rebuild"/> + <allow service="minimap.rebuild"/> + <allow service="static.form.pdf"/> + <allow service="create.pdf"/> + <allow service="banner"/> <allow service="map.addServices"/> <allow service="map.addServicesExt"/> Added: trunk/web/intermap/xsl/im_pdf_form.xsl =================================================================== --- trunk/web/intermap/xsl/im_pdf_form.xsl (rev 0) +++ trunk/web/intermap/xsl/im_pdf_form.xsl 2007-08-21 12:25:56 UTC (rev 746) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="html"/> + + <xsl:template match="/"> + + <div> + Page size: + <select id="pdf_pagesize"> + <option value="A4">A4</option> + <option value="letter">Letter</option> + <option value="legal">Legal</option> + </select> + + Orientation: + <select id="pdf_orientation"> + <option value="portrait">Portrait</option> + <option value="landscape">Landscape</option> + </select> + <br/> + +<!-- <input type="radio" name="orientation" value="portrait">Portrait</input> + <input type="radio" name="orientation" value="landscape">Landscape</input> + <br/> +--> + <input type="checkbox" name="pdf_layerlist" id="pdf_layerlist" checked="true">Print layerlist</input> + <br/> + + <input type="checkbox" name="pdf_details" id="pdf_details">Print details</input> + <br/> + + <input type="checkbox" name="pdf_boundingbox" id="pdf_boundingbox">Print bounding box</input> + <br/> + + <div id="im_requestpdf"> + <button onClick="javascript:im_requestPDF();">Generate PDF</button> + </div> + <div id="im_requestingpdf" class="im_extra_status" style="display:none;"> + Building PDF... please wait... + </div> + <div id="im_builtpdf" class="im_extra_status" style="display:none;"> + PDF successfully built + </div> + + </div> + + </xsl:template> + +<!-- + <div id="im_wbtitle"> + <h1>Export this map as PDF</h1> + </div> + <div id="im_wbcloser"> + <img title="Close" src="/intermap/images/close.png"/> + </div> + <div class="im_wbcontent" id="im_createPDF"> + <h1 id="im_serverList_title">TODO</h1> + </div> +--> +</xsl:stylesheet> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-08-23 17:44:49
|
Revision: 755 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=755&view=rev Author: e_tajariol Date: 2007-08-23 10:44:48 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Major changes in layers handling: - the layer list is now created on server via XSL, and no longer via JS on client. - added layers are hilited in green. - when there is only one layer, it has no "delete" button. - up and down buttons in layer list now work. Disabled scriptaculous effects under IE. Removed many unused JS functions. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/services/map/DelService.java trunk/web/intermap/WEB-INF/config.xml trunk/web/intermap/intermap-embedded.css trunk/web/intermap/scripts/etj.js trunk/web/intermap/scripts/im_ajax.js trunk/web/intermap/scripts/im_layers.js trunk/web/intermap/xml/user-profiles.xml Added Paths: ----------- trunk/src/org/wfp/vam/intermap/services/map/layers/MoveDown.java trunk/src/org/wfp/vam/intermap/services/map/layers/MoveUp.java trunk/web/intermap/xsl/im_get-layers-embedded.xsl Modified: trunk/src/org/wfp/vam/intermap/services/map/DelService.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/map/DelService.java 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/src/org/wfp/vam/intermap/services/map/DelService.java 2007-08-23 17:44:48 UTC (rev 755) @@ -1,18 +1,13 @@ package org.wfp.vam.intermap.services.map; -import org.jdom.*; - -import jeeves.interfaces.*; -import jeeves.server.*; -import jeeves.server.context.*; - -import org.wfp.vam.intermap.kernel.map.*; - +import jeeves.interfaces.Service; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.MapMerger; -//============================================================================= - -/** main.result service. shows search results +/** */ public class DelService implements Service @@ -33,12 +28,12 @@ // Get the MapMerger object from the user session MapMerger mm = MapUtil.getMapMerger(context); - MapUtil.setVisibleLayers(params, mm); + MapUtil.setVisibleLayers(params, mm); // ETj: ??? mm.delService(id); - return null; + return mm.toElementSimple(); } - + } //============================================================================= Added: trunk/src/org/wfp/vam/intermap/services/map/layers/MoveDown.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/map/layers/MoveDown.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/services/map/layers/MoveDown.java 2007-08-23 17:44:48 UTC (rev 755) @@ -0,0 +1,33 @@ +package org.wfp.vam.intermap.services.map.layers; + + +import jeeves.interfaces.Service; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; +import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.services.map.MapUtil; + +public class MoveDown implements Service +{ + public void init(String appPath, ServiceConfig config) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + public Element exec(Element params, ServiceContext context) throws Exception + { + int id = Integer.parseInt(params.getChildText(Constants.MAP_SERVICE_ID)); + MapMerger mm = MapUtil.getMapMerger(context); + mm.moveServiceDown(id); + return mm.toElementSimple(); + } + +} + +//============================================================================= + Added: trunk/src/org/wfp/vam/intermap/services/map/layers/MoveUp.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/map/layers/MoveUp.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/services/map/layers/MoveUp.java 2007-08-23 17:44:48 UTC (rev 755) @@ -0,0 +1,32 @@ +package org.wfp.vam.intermap.services.map.layers; + +import jeeves.interfaces.Service; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; +import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.services.map.MapUtil; + +public class MoveUp implements Service +{ + public void init(String appPath, ServiceConfig config) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + public Element exec(Element params, ServiceContext context) throws Exception + { + int id = Integer.parseInt(params.getChildText(Constants.MAP_SERVICE_ID)); + MapMerger mm = MapUtil.getMapMerger(context); + mm.moveServiceUp(id); + return mm.toElementSimple(); + } + +} + +//============================================================================= + Modified: trunk/web/intermap/WEB-INF/config.xml =================================================================== --- trunk/web/intermap/WEB-INF/config.xml 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/WEB-INF/config.xml 2007-08-23 17:44:48 UTC (rev 755) @@ -171,8 +171,10 @@ </service> <!-- ETj --> - <service name="map.addServices.xml"> + <service name="map.addServices.embedded"> <class name=".services.map.AddServices" /> + + <output sheet="im_get-layers-embedded.xsl" /> </service> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> @@ -229,9 +231,23 @@ <output sheet="im_get-layers.xsl" /> </service> --> + + <service name="map.getLayers.embedded"> + <class name=".services.map.layers.GetOrder" /> + + <output sheet="im_get-layers-embedded.xsl" /> + </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="map.layers.deleteLayer"> + <class name=".services.map.DelService" /> + <output sheet="im_get-layers-embedded.xsl" /> + </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="map.layers.getOrder"> <class name=".services.map.layers.GetOrder" /> </service> @@ -240,8 +256,26 @@ <service name="map.layers.setOrder"> <class name=".services.map.layers.SetOrder" /> + + <!-- ETJ --> + <output sheet="im_get-layers-embedded.xsl" /> </service> + + + <service name="map.layers.moveUp"> + <class name=".services.map.layers.MoveUp" /> + + <output sheet="im_get-layers-embedded.xsl" /> + </service> + + <service name="map.layers.moveDown"> + <class name=".services.map.layers.MoveDown" /> + + <output sheet="im_get-layers-embedded.xsl" /> + </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="map.layers.setTransparency"> @@ -333,28 +367,9 @@ <output sheet="im_identify.xsl" /> </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- - <service name="map.service.moveUp"> - <class name=".services.map.MoveServiceUp" /> - - <output forward="map.getMain" /> - </service> - --> - - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - -<!-- - <service name="map.service.moveDown"> - <class name=".services.map.MoveServiceDown" /> - - <output forward="map.getMain" /> - </service> - --> - - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <service name="map.service.getLegend"> <class name=".services.map.GetLegend" /> @@ -410,9 +425,6 @@ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <service name="map.layers.deleteLayer"> - <class name=".services.map.DelService" /> - </service> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> Modified: trunk/web/intermap/intermap-embedded.css =================================================================== --- trunk/web/intermap/intermap-embedded.css 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/intermap-embedded.css 2007-08-23 17:44:48 UTC (rev 755) @@ -524,6 +524,10 @@ background-color: #ccf; } +div#im_layers li.im_newLayer{ + background-color: #8ae38a; +} + div#im_layers li td { padding: 3px; /* border-style: solid;*/ Modified: trunk/web/intermap/scripts/etj.js =================================================================== --- trunk/web/intermap/scripts/etj.js 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/scripts/etj.js 2007-08-23 17:44:48 UTC (rev 755) @@ -11,7 +11,7 @@ function im_init() { im_mm_initTextControls($('northBL'), $('eastBL'), $('southBL'), $('westBL')); - Event.observe('openIMBtn', 'click', function(){openIntermap()} ); + Event.observe('openIMBtn', 'click', function(){openIntermap()} ); //imc_load(); im_mm_refreshNeeded(); // load minimap @@ -23,46 +23,52 @@ function openIntermap() { - if(im_1stTimeIntermap) - { - im_1stTimeIntermap = false; + if(im_1stTimeIntermap) + { + im_1stTimeIntermap = false; + + $('openIMBtn').hide(); + $('loadIMBtn').show(); + + imc_init_loadSkel(); + return; // loadSkel should call us back + } - $('openIMBtn').hide(); - $('loadIMBtn').show(); + $('openIMBtn').hide(); + $('loadIMBtn').hide(); + $('closeIMBtn').show(); - imc_init_loadSkel(); - return; // loadSkel should call us back - } - - $('openIMBtn').hide(); - $('loadIMBtn').hide(); - $('closeIMBtn').show(); - -// These effects won't work on IE, so we're not going to use them -/* + if( ! Prototype.Browser.IE ) + { Effect.BlindDown('im_map'); Effect.BlindDown('im_mapImg'); Effect.BlindDown('fillMeWithIntermap'); -*/ + } + else + { $('im_map').show(); $('im_mapImg').show(); $('fillMeWithIntermap').show(); + } // forceIErefresh(); } function closeIntermap() { - $('closeIMBtn').hide(); - $('openIMBtn').show(); - -// These effects won't work on IE, so we're not going to use them -/* + $('closeIMBtn').hide(); + $('openIMBtn').show(); + + if( ! Prototype.Browser.IE ) + { Effect.BlindUp('im_map'); Effect.BlindUp('fillMeWithIntermap'); -*/ + } + else + { $('im_map').hide(); $('fillMeWithIntermap').hide(); + } } function imc_init_loadSkel() @@ -85,7 +91,7 @@ // Dinamically generate content var im = $('fillMeWithIntermap'); im.innerHTML = req.responseText; - $('im_mm_wait').hide(); //style.display='none'; + $('im_mm_wait').hide(); new Effect.Pulsate('openIMBtn'); refreshNeeded(false, im_init_bmLoaded); @@ -144,8 +150,9 @@ */ function runIM_addService(url, service, type) { - imc_addService(url, service, type, function() { - imc_reloadLayers(); + imc_addService(url, service, type, function(req) { + im_buildLayerList(req); + //imc_reloadLayers(); imc_mm_update(im_mm_width, im_mm_height, null); }); } Modified: trunk/web/intermap/scripts/im_ajax.js =================================================================== --- trunk/web/intermap/scripts/im_ajax.js 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/scripts/im_ajax.js 2007-08-23 17:44:48 UTC (rev 755) @@ -7,8 +7,8 @@ function imc_reloadLayers() { - var url = '/intermap/srv/en/map.layers.getOrder'; - +/* var url = '/intermap/srv/en/map.layers.getOrder';*/ + var url = '/intermap/srv/en/map.getLayers.embedded'; var myAjax = new Ajax.Request ( url, { @@ -25,22 +25,6 @@ * * *****************************************************************************/ -function updateInspector(layerId) -{ - var url = '/intermap/srv/en/map.layers.getInspectorData'; - var pars = 'id=' + layerId; - - var myAjax = new Ajax.Request ( - url, - { - method: 'get', - parameters: pars, - onComplete: updateInspectorControls, - onFailure: reportError - } - ); -} - // start ajax transaction to set the layer order function imc_setLayersOrder(order) { @@ -52,7 +36,11 @@ { method: 'get', parameters: pars, - onComplete: refreshNeeded, + onComplete: function(req) + { + im_buildLayerList(req); + refreshNeeded(); + }, onFailure: reportError } ); @@ -73,7 +61,7 @@ { method: 'get', parameters: pars, - onComplete: refreshNeeded, + onComplete: function(req) { refreshNeeded(true) }, onFailure: reportError } ); @@ -108,22 +96,6 @@ * * *****************************************************************************/ -// start ajax transaction to delete a layer -function imc_deleteLayer(id) -{ - var url = '/intermap/srv/en/map.layers.deleteLayer'; - var pars = 'id=' + id ; - - var myAjax = new Ajax.Request ( - url, - { - method: 'get', - parameters: pars, - onComplete: refreshNeeded, - onFailure: reportError - } - ); -} /***************************************************************************** * * @@ -316,7 +288,8 @@ { method: 'get', parameters: pars, - onComplete: function(req) { + onComplete: function(req) + { updateMapImage(req); if( doUpdateMM ) // !!! check if this refresh is not due to a minimap action, or we'll get a refresh loop !!! @@ -461,7 +434,7 @@ */ function imc_addService(surl, service, type, callback) { - var url = '/intermap/srv/en/map.addServices.xml'; + var url = '/intermap/srv/en/map.addServices.embedded'; var pars = 'url=' + surl + '&service=' + service + '&type=' + type; var myAjax = new Ajax.Request ( @@ -479,7 +452,7 @@ function imc_addServices(surl, serviceArray, type, callback) { - var url = '/intermap/srv/en/map.addServices.xml'; + var url = '/intermap/srv/en/map.addServices.embedded'; var pars = 'url=' + surl + '&type=' + type; serviceArray.each( Modified: trunk/web/intermap/scripts/im_layers.js =================================================================== --- trunk/web/intermap/scripts/im_layers.js 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/scripts/im_layers.js 2007-08-23 17:44:48 UTC (rev 755) @@ -10,200 +10,19 @@ if( ! $('im_layersDiv') ) // map viewer not yet loaded return; - var layers = req.responseXML.getElementsByTagName('layer'); - - // delete all layers from the list - var ul = $('im_layersDiv').getElementsByTagName('ul')[0]; - deleteChildNodes(ul); - - // add each layer to the list - for (var i = 0; i < layers.length; i++) - { -// alert('Adding layer ' + layers[i].getAttribute('title')); - var title = Builder.node('p',{},layers[i].getAttribute('title')); -// var title = document.createTextNode(layers[i].getAttribute('title')); - - var id = layers[i].getAttribute('id'); - var transp = layers[i].getAttribute('transparency'); - - var addup = i>0; - var adddown = (i<layers.length-1)&&(layers.length>1); - -//zalert('Appending layer ' + layers[i].getAttribute('title')); - appendToLayerList(ul, title, id, transp,addup, adddown); - } - - createSortable(); - - // activate the first layer if none active - if (!activeLayerId) - activateMapLayer(layers[0].getAttribute('id')); - - forceIErefresh(); -} - - -function forceIErefresh() -{ - // Force IE to refresh the page (layers are not properly displayed without this workaround - var dummy = Builder.node('div'); - document.appendChild(dummy); - document.removeChild(dummy); -} - - - -// Appends a single layer to the layer list -function appendToLayerList(list, title, id, transp, addup, adddown) // layer in a TABLEs layout -{ - var li = Builder.node('li', {id: 'layerList_' + id}); - - var toggleLayer = Builder.node('img' , - { - id: 'visibility_' + id, - className: 'im_layerControl', - src: '/intermap/images/showLayer.png', - title:'Toggle layer visibility' // FIXME: i18n this string - }); - - var delLayer = Builder.node('img', - { - id: 'deleteLayer_' + id, - className: 'im_layerButton', - src: '/intermap/images/deleteLayer.png', - title: 'Remove layer' // FIXME: i18n this string - }); - - var showLayerMD = Builder.node('img', - { - id: 'showLayerMD_' + id, - className: 'im_layerButton', - src: '/intermap/images/info.png', - title: 'Show metadata' // FIXME: i18n this string - }); - - var legend = Builder.node('img', - { - id: 'legend_' + id, - className: 'im_layerButton', - src: '/intermap/images/legend.png', - title: 'Show legend' // FIXME: i18n this string - }); - -/* var trans = Builder.node('select', - { - id: "im_transp_"+id, - className: "layerSelectTransp" - }); -*/ - var trans = document.createElement('select'); - trans.setAttribute("id", "im_transp_"+id); - trans.setAttribute("className", "layerSelectTransp"); - - for (var t = 100; t >= 0; t-=10) { - var opt = document.createElement('option'); - opt.setAttribute("value", t); - if(transp==t) - { - //alert ("Transp for " + title + " is set at " + t); - opt.setAttribute('selected', 'true'); - } - var label = t+"%"; - if(t==100) - label = "opaque"; // FIXME i18n - - opt.innerHTML=label; - trans.appendChild(opt); - } - - // do layout - list.appendChild(li); - - var table = Builder.node('table'); - li.appendChild(table); + oldid = activeLayerId; + $('im_layersDiv').innerHTML = req.responseText; + activateMapLayer(oldid, true); - var tbody = Builder.node('tbody'); - table.appendChild(tbody); - - var trmainicons = Builder.node('tr'); - tbody.appendChild(trmainicons); - - var tdmainicons = Builder.node('td', - { - rowspan: "2", - height: "35px", - className: 'im_layerControl' - }); - - trmainicons.appendChild(tdmainicons); - - tdmainicons.appendChild(toggleLayer); - - if(addup) - { - var upbtn = Builder.node('img', - { - id: 'im_layerUp_'+id, - className: 'im_layerControl', - //style: 'position:absolute; bottom:3px;', - src: '/intermap/images/im_moveup.gif', - title: 'Move layer up' // FIXME: i18n this string - }); - tdmainicons.appendChild(upbtn); - } - - if(adddown) - { - var downbtn = Builder.node('img', - { - id: 'im_layerDown_'+id, - className: 'im_layerControl', - src: '/intermap/images/im_movedown.gif', - title: 'Move layer down' // FIXME: i18n this string - }); - - tdmainicons.appendChild(downbtn); - } - - var tdtitle = Builder.node('td'); - trmainicons.appendChild(tdtitle); - tdtitle.appendChild(title); - - var trcontrols = Builder.node('tr', {id: 'layerControl_' + id}); -/* trcontrols.style.display = "none"; */ - tbody.appendChild(trcontrols); - - var tdcontrols = Builder.node('td', { /*colspan:"2" */}); - trcontrols.appendChild(tdcontrols); - -/* tdcontrols.appendChild(toggleLayer);*/ - tdcontrols.appendChild(delLayer); - tdcontrols.appendChild(legend); - tdcontrols.appendChild(showLayerMD); - tdcontrols.appendChild(trans); - - //ker.wrap(this, function() { - //$(trcontrols).hide(); - //} )(); - -//alert("observers"); - // add event observers (mousedown to select layer and dblclick to zoom to layer) - Event.observe('layerList_' + id, 'mousedown', function(e){ activateMapLayer(id); }); -// Event.observe('layerList_' + id, 'dblclick', function(e){ openInspector(id); }); - Event.observe('layerList_' + id, 'dblclick', function(e){ layerDblClickListener(id, e); }); - Event.observe('visibility_' + id, 'click', function(e){ visibilityButtonListener(id, e); }); - Event.observe('legend_' + id, 'click', function(e){ showLegend(id); }); - Event.observe('deleteLayer_' + id, 'click', function(e){ im_deleteLayer(id); }); - Event.observe('im_transp_' + id, 'change', function(e){ im_layerTransparencyChanged(id); }); -// TODO Event.observe('showLayerMD_' + id, 'click', function(e){ }); - $(trcontrols).hide(); + if( ! Prototype.Browser.IE ) + createSortable(); } - + // Makes the layer list sortable function createSortable() { Sortable.create ( - 'im_layerList', + $('im_layerList'), { dropOnEmpty:true,containment:['im_layerList'],constraint:false, onUpdate:function(){ layersOrderChanged(Sortable.serialize('im_layerList')); } @@ -218,37 +37,23 @@ imc_setLayersOrder(newOrder); } -// Opens the inspector -function openInspector(id) -{ - Element.show('im_inspector'); -} -// Closes the inspector -function closeInspector() -{ - Element.hide('im_inspector'); -} - - /***************************************************************************** * * Layers * *****************************************************************************/ -function layerDblClickListener(id, e) +function layerDblClickListener(id) { deleteAoi(); imc_zoomToLayer(id); } -function visibilityButtonListener(id, e) -{ - toggleVisibility(id); -} -function setLayerVisibility(req, id) { + +function setLayerVisibility(req, id) +{ // get visibility value from response var visibility = req.responseXML.getElementsByTagName('visible')[0].firstChild.nodeValue; @@ -262,149 +67,168 @@ refreshNeeded(); } -function activateMapLayer(id) +/***************************************************************************** + * + * Activation + * + *****************************************************************************/ + +function activateMapLayer(id, keepnew) { var mapLayer = $('layerList_' + id); - disactivateAllMapLayers(); + disactivateAllMapLayers(keepnew); mapLayer.className = 'im_activeLayer'; - //$('layerControl_' + id).style.display = "table-row"; $('layerControl_' + id).show(); activeLayerId = id; - - //updateInspector(id); } - -function updateInspectorControls(req) +function disactivateAllMapLayers(keepnew) { - // transparency slider -// var offsetX = Position.cumulativeOffset($('transparencySlider'))[0]; -// var transparency = parseFloat(req.responseXML.getElementsByTagName('transparency')[0].firstChild.nodeValue); -// $('im_transparencyHandle').style.left = Math.round(transparency / 100 * 95) + 'px'; // handler width is 5px - - // transparency value -// $('im_transparencyValue').innerHTML = transparency; -} - -function disactivateAllMapLayers() -{ -// var ul = $('layerList'); var li = $('im_layersDiv').getElementsByTagName('li'); var layers = $A(li); layers.each ( function(mapLayer) { - mapLayer.className = 'im_inactiveLayer'; + if( ! (keepnew && mapLayer.className == "im_newLayer") ) + { + mapLayer.className = 'im_inactiveLayer'; + } var trList=mapLayer.getElementsByTagName('tr'); $A(trList).each( function(tr) { if( new String(tr.id).search('layerControl_') != -1) - tr.hide(); + $(tr).hide(); } ); } ); } +/***************************************************************************** + * + * Layer position + * + *****************************************************************************/ +function im_layerMoveDown(id) +{ + var url = '/intermap/srv/en/map.layers.moveDown'; + var myAjax = new Ajax.Request ( + url, + { + parameters: 'id='+id, + method: 'get', + onComplete: im_buildLayerList + } + ); +} +function im_layerMoveUp(id) +{ + var url = '/intermap/srv/en/map.layers.moveUp'; + var myAjax = new Ajax.Request ( + url, + { + parameters: 'id='+id, + method: 'get', + onComplete: im_buildLayerList + } + ); +} + + /***************************************************************************** * * Delete layer * *****************************************************************************/ -function deleteButtonListener() +function im_deleteLayer(id) { - if (activeLayerId != null) + // won't remove last layer + var llist = $('im_layerList'); + var nodes=llist.getElementsByTagName('li'); + if( $A(nodes).length == 1) { - imc_deleteLayer(activeLayerId); - deleteLayerFromList(activeLayerId); - //activeLayerId = null; + // this should not happen, so never mind i18n here + alert("Can't remove last layer"); + return; } + + // activate next available layer + var nextid= im_getNextActivableLayer(id); + if(nextid) + activateMapLayer(nextid); + + // delete it! + imc_deleteLayer(id); + //deleteLayerFromList(id); } -function im_deleteLayer(id) +// start ajax transaction to delete a layer +function imc_deleteLayer(id) { - // won't remove last layer - var llist = $('im_layerList'); - var nodes=llist.getElementsByTagName('li'); - if( $A(nodes).length == 1) - { - alert("Can't remove last layer"); // fixme i18n! - return; - } - - imc_deleteLayer(id); - deleteLayerFromList(id); + var url = '/intermap/srv/en/map.layers.deleteLayer'; + var pars = 'id=' + id ; + + var myAjax = new Ajax.Request ( + url, + { + method: 'get', + parameters: pars, + onComplete: function(req) + { + im_buildLayerList(req); + refreshNeeded(); + }, + onFailure: reportError + } + ); } - -function deleteLayerFromList(id) +/* +## If layer id has to be removed, this function computes next layer to be activated. +*/ +function im_getNextActivableLayer(id) { - var ul = $('im_layersDiv').getElementsByTagName('ul')[0]; - var child = $('layerList_' + id); - - if (child != null) + var child = $('layerList_' + id); + if (child == null) + return null; + else { - if (id==activeLayerId) - { - // choose the layer to activate next - var nextActiveLayer; - if (child.nextSibling != null) - nextActiveLayer = (child.nextSibling) - else if (child.previousSibling != null) - nextActiveLayer = (child.previousSibling) - else nextActiveLayer = null; - - // activate the layer - if (nextActiveLayer != null) + if (id != activeLayerId) + return activeLayerId; + else { - var t = nextActiveLayer.getAttribute('id'); - var nextActiveLayerId = t.substr(t.indexOf('_') + 1); - activateMapLayer(nextActiveLayerId); + // choose the layer to activate next + var nextActiveLayer = child.nextSibling; + if (nextActiveLayer == null) + nextActiveLayer = child.previousSibling; // may also be null: ok + + if(nextActiveLayer == null) + return null; + else + { + var t = nextActiveLayer.getAttribute('id'); + var nextActiveLayerId = t.substr(t.indexOf('_') + 1); + return nextActiveLayerId; + } } - } - - ul.removeChild(child); } } /***************************************************************************** * - * Add layer - * - *****************************************************************************/ - -function addButtonListener() -{ - setStatus('idle'); - $('addLayers').className = 'im_visible'; - setAddLayersWindowContent(); -} - - -/***************************************************************************** - * * Layer transparency * *****************************************************************************/ - -function transparencySliderMoved(transparency) -{ - if (activeLayerId != null) - { - imc_setLayerTransparency(activeLayerId, transparency); - } -} - function im_layerTransparencyChanged(id) { Modified: trunk/web/intermap/xml/user-profiles.xml =================================================================== --- trunk/web/intermap/xml/user-profiles.xml 2007-08-21 21:01:11 UTC (rev 754) +++ trunk/web/intermap/xml/user-profiles.xml 2007-08-23 17:44:48 UTC (rev 755) @@ -14,7 +14,7 @@ <allow service="banner"/> <allow service="map.addServices"/> <allow service="map.addServicesExt"/> - <allow service="map.addServices.xml"/> + <allow service="map.addServices.embedded"/> <allow service="map.getFrames"/> <allow service="mapContexts.get"/> <allow service="mapServers.listServers"/> @@ -26,6 +26,7 @@ <allow service="mapServers.getServices.xml"/> <allow service="map.get"/> <allow service="map.getLayers"/> + <allow service="map.getLayers.embedded"/> <allow service="map.action"/> <allow service="map.move"/> <allow service="map.fullExtent"/> @@ -52,6 +53,8 @@ <allow service="map.layers.deleteLayer"/> <allow service="map.layers.getOrder"/> <allow service="map.layers.setOrder"/> + <allow service="map.layers.moveUp"/> + <allow service="map.layers.moveDown"/> <allow service="map.layers.setTransparency"/> <allow service="map.layers.getInspectorData"/> <allow service="map.layers.toggleVisibility"/> Added: trunk/web/intermap/xsl/im_get-layers-embedded.xsl =================================================================== --- trunk/web/intermap/xsl/im_get-layers-embedded.xsl (rev 0) +++ trunk/web/intermap/xsl/im_get-layers-embedded.xsl 2007-08-23 17:44:48 UTC (rev 755) @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:template match="/"> + <ul id = "im_layerList"> + <xsl:apply-templates select="//layer" /> + </ul> + </xsl:template> + + + <!-- Layers --> + <xsl:template match="//layer"> + + <li id="layerList_{@id}" + onmousedown="activateMapLayer({@id})" + ondblclick="layerDblClickListener({@id})"> + + <xsl:variable name="currid"><xsl:value-of select="@id" /></xsl:variable> + <xsl:if test="//newLayer/@id=$currid"> + <xsl:attribute name="class" >im_newLayer</xsl:attribute> + </xsl:if> + +<!-- + + <xsl:variable name="action">im_mapServerSelected(<xsl:value-of select="@id" />,"<xsl:value-of select="@name" />");</xsl:variable> + <li id="im_mapserver_{@id}" onclick="{$action}"><a><xsl:value-of select="@name" /></a></li> +--> + <table> + <tbody> + <tr height="35px"> + <td rowspan="2" height="35px" class="im_layerControl"> + <img id="visibility_{@id}" class="im_layerControl" + onclick="toggleVisibility({@id})" + src="/intermap/images/showLayer.png" title="Toggle layer visibility"></img> + <xsl:if test="position()>1"> + <img id="im_layerUp_{@id}" class="im_layerControl" + onclick="im_layerMoveUp({@id})" + src="/intermap/images/im_moveup.gif" title="Move layer up"/> + </xsl:if> + <xsl:if test="position() < last()"> + <img id="im_layerDown_{@id}" class="im_layerControl" + onclick="im_layerMoveDown({@id})" + src="/intermap/images/im_movedown.gif" title="Move layer down"/> + </xsl:if> + </td> + + <td> + <p><xsl:value-of select="@title" /></p> + </td> + </tr> + + <tr id="layerControl_{@id}" style="display:none;"> + <td> + <xsl:if test="last()>1"> <!-- we need at least one layer, so last one is not removeable --> + <img id="deleteLayer_{@id}" class="im_layerButton" + onclick="im_deleteLayer({@id})" + src="/intermap/images/deleteLayer.png" title="Remove layer"/> + </xsl:if> + <img id="legend_{@id}" class="im_layerButton" + onclick="showLegend({@id})" + src="/intermap/images/legend.png" title="Show legend"/> + <img id="showLayerMD_{@id}" class="im_layerButton" + src="/intermap/images/info.png" title="Show layer info"/> + <select id="im_transp_{@id}" class="layerSelectTransp" + onchange="im_layerTransparencyChanged({@id})" > + <xsl:call-template name="fillTransparencyOptions"> + <xsl:with-param name="transparency"><xsl:value-of select="@transparency" /></xsl:with-param> + </xsl:call-template> + </select> + </td> + + </tr> + </tbody> + + </table> + + </li> + + </xsl:template> + + + <xsl:template name="fillTransparencyOptions"> + <xsl:param name="transparency"/> + + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">100</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">90</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">80</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">70</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">60</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">50</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">40</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">30</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">20</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">10</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + <xsl:call-template name="transpOption"> + <xsl:with-param name="value">0</xsl:with-param> + <xsl:with-param name="transp"><xsl:value-of select="$transparency" /></xsl:with-param> + </xsl:call-template> + </xsl:template> + + + <xsl:template name="transpOption"> + <xsl:param name="value"/> + <xsl:param name="transp"/> + + <option value="{$value}"> + <xsl:if test="$transp = $value"> + <xsl:attribute name="selected" >true</xsl:attribute> + </xsl:if> + + <xsl:choose> + <xsl:when test="$value=100">Opaque</xsl:when> +<!-- <xsl:when test="$value=0">Transparent</xsl:when>--> + <xsl:otherwise><xsl:value-of select="$value"/>%</xsl:otherwise> + </xsl:choose> + + </option> + </xsl:template> + +</xsl:stylesheet> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tic...@us...> - 2007-08-24 15:54:32
|
Revision: 758 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=758&view=rev Author: ticheler Date: 2007-08-24 08:54:35 -0700 (Fri, 24 Aug 2007) Log Message: ----------- Merged set Web Map Context from a URL (remote WMC document) back into InterMap Modified Paths: -------------- trunk/web/intermap/WEB-INF/config.xml trunk/web/intermap/xml/user-profiles.xml Added Paths: ----------- trunk/src/org/wfp/vam/intermap/services/wmc/SetWmcFromURL.java Added: trunk/src/org/wfp/vam/intermap/services/wmc/SetWmcFromURL.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/wmc/SetWmcFromURL.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/services/wmc/SetWmcFromURL.java 2007-08-24 15:54:35 UTC (rev 758) @@ -0,0 +1,108 @@ +package org.wfp.vam.intermap.services.wmc; + +import java.util.*; +import java.net.*; +import java.io.*; + +import org.jdom.*; + +import jeeves.interfaces.*; +import jeeves.server.*; +import jeeves.server.context.*; + +import org.wfp.vam.intermap.kernel.map.*; +import java.net.URLDecoder; +import jeeves.utils.Xml; +import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; +import org.wfp.vam.intermap.services.map.MapUtil; +import org.wfp.vam.intermap.http.ConcurrentHTTPTransactionHandler; + +//============================================================================= + +/** main.result service. shows search results + */ + +public class SetWmcFromURL implements Service +{ + public void init(String appPath, ServiceConfig config) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + /** + * Method exec + * + * @param params an Element + * @param context a ServiceContext + * + * @return an Element + * + * @exception Exception + * + */ + public Element exec(Element params, ServiceContext context) throws Exception + { + String url = params.getChildText("url"); + + URL u = new URL(url); + HttpURLConnection conn = (HttpURLConnection)u.openConnection(); + BufferedInputStream is = new BufferedInputStream(conn.getInputStream()); + Element mapContext = Xml.loadStream(is); + conn.disconnect(); + + String stContext = mapContext.getText(); + String decoded = URLDecoder.decode(stContext); + + mapContext = Xml.loadString(decoded, false); + + // Create a new MapMerger object + MapMerger mm = addContextLayers(mapContext); // DEBUG + + // Set image size if not set + String size = (String)context.getUserSession().getProperty(Constants.SESSION_SIZE); + if (size == null) + context.getUserSession().setProperty(Constants.SESSION_SIZE, "small"); + + // Update the user session + context.getUserSession().setProperty(Constants.SESSION_MAP, mm); + + return new Element("response"); + } + + public static MapMerger addContextLayers(Element context) throws Exception + { + MapMerger mm = new MapMerger(); + + // Add each layer in the context to the map + Namespace ns = org.jdom.Namespace.getNamespace("http://www.opengeospatial.net/context"); + List layers = context.getChild("LayerList", ns).getChildren("Layer", ns); + + for (Iterator i = layers.iterator(); i.hasNext(); ) + { + Element layer = (Element)i.next(); + + int serverType = 2; + Element olr = layer.getChild("Server", ns).getChild("OnlineResource", ns); + + Namespace linkNs = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink"); + String serverUrl = olr.getAttributeValue("href", linkNs); + String serviceName = layer.getChildText("Name", ns); + String vsp = layer.getChildText("vendor_spec_par"); // vendor specific parameters + + try { + MapUtil.addService(serverType, serverUrl, serviceName, vsp, mm); + } catch (Exception e) { e.printStackTrace(); } // DEBUG + } + + mm.setBoundingBox(new BoundingBox()); + return mm; + } + +} + +//============================================================================= + Modified: trunk/web/intermap/WEB-INF/config.xml =================================================================== --- trunk/web/intermap/WEB-INF/config.xml 2007-08-24 15:37:41 UTC (rev 757) +++ trunk/web/intermap/WEB-INF/config.xml 2007-08-24 15:54:35 UTC (rev 758) @@ -488,13 +488,11 @@ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- <service name="wmc.setContextFromURL"> <class name=".services.wmc.SetWmcFromURL"/> <output forward="map.getMain"/> </service> - --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> Modified: trunk/web/intermap/xml/user-profiles.xml =================================================================== --- trunk/web/intermap/xml/user-profiles.xml 2007-08-24 15:37:41 UTC (rev 757) +++ trunk/web/intermap/xml/user-profiles.xml 2007-08-24 15:54:35 UTC (rev 758) @@ -50,6 +50,7 @@ <allow service="map.setContext"/> <allow service="map.getFeatures"/> <allow service="wmc.setContext"/> + <allow service="wmc.setContextFromURL"/> <allow service="map.layers.deleteLayer"/> <allow service="map.layers.getOrder"/> <allow service="map.layers.setOrder"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-30 11:42:18
|
Revision: 766 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=766&view=rev Author: acarboni Date: 2007-08-30 04:42:08 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Added proxy credentials Modified Paths: -------------- trunk/gast/setup/db/Settings.ddf trunk/web/geonetwork/WEB-INF/lib/jeeves.jar trunk/web/geonetwork/loc/en/xml/config.xml trunk/web/geonetwork/scripts/config/model.js trunk/web/geonetwork/scripts/config/view.js trunk/web/geonetwork/xsl/config/config.xsl trunk/web/geonetwork/xsl/xml/config.xsl Modified: trunk/gast/setup/db/Settings.ddf =================================================================== --- trunk/gast/setup/db/Settings.ddf 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/gast/setup/db/Settings.ddf 2007-08-30 11:42:08 UTC (rev 766) @@ -39,6 +39,8 @@ 51 50 use false 52 50 host 53 50 port +54 50 username +55 50 password 60 1 feedback 61 60 email Modified: trunk/web/geonetwork/WEB-INF/lib/jeeves.jar =================================================================== (Binary files differ) Modified: trunk/web/geonetwork/loc/en/xml/config.xml =================================================================== --- trunk/web/geonetwork/loc/en/xml/config.xml 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/web/geonetwork/loc/en/xml/config.xml 2007-08-30 11:42:08 UTC (rev 766) @@ -18,6 +18,7 @@ <proxy>Proxy</proxy> <use>Use</use> + <username>Username</username> <feedback>Feedback</feedback> <email>EMail</email> Modified: trunk/web/geonetwork/scripts/config/model.js =================================================================== --- trunk/web/geonetwork/scripts/config/model.js 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/web/geonetwork/scripts/config/model.js 2007-08-30 11:42:08 UTC (rev 766) @@ -39,11 +39,13 @@ PROXY_USE : xml.evalXPath(node, 'proxy/use'), PROXY_HOST : xml.evalXPath(node, 'proxy/host'), PROXY_PORT : xml.evalXPath(node, 'proxy/port'), + PROXY_USER : xml.evalXPath(node, 'proxy/username'), + PROXY_PASS : xml.evalXPath(node, 'proxy/password'), FEEDBACK_EMAIL : xml.evalXPath(node, 'feedback/email'), FEEDBACK_MAIL_HOST: xml.evalXPath(node, 'feedback/mailServer/host'), FEEDBACK_MAIL_PORT: xml.evalXPath(node, 'feedback/mailServer/port'), REMOVEDMD_DIR : xml.evalXPath(node, 'removedMetadata/dir'), - + LDAP_USE : xml.evalXPath(node, 'ldap/use'), LDAP_HOST : xml.evalXPath(node, 'ldap/host'), LDAP_PORT : xml.evalXPath(node, 'ldap/port'), @@ -111,6 +113,8 @@ ' <use>{PROXY_USE}</use>'+ ' <host>{PROXY_HOST}</host>'+ ' <port>{PROXY_PORT}</port>'+ +' <username>{PROXY_USER}</username>'+ +' <password>{PROXY_PASS}</password>'+ ' </proxy>'+ ' <feedback>'+ ' <email>{FEEDBACK_EMAIL}</email>'+ Modified: trunk/web/geonetwork/scripts/config/view.js =================================================================== --- trunk/web/geonetwork/scripts/config/view.js 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/web/geonetwork/scripts/config/view.js 2007-08-30 11:42:08 UTC (rev 766) @@ -29,13 +29,15 @@ { id:'feedback.mail.host', type:'hostname' }, { id:'feedback.mail.port', type:'integer', minValue:25, maxValue:65535, empty:true }, - { id:'proxy.host', type:'length', minSize :0, maxSize :200 }, - { id:'proxy.host', type:'hostname' }, - { id:'proxy.port', type:'integer', minValue:21, maxValue:65535, empty:true }, + { id:'proxy.host', type:'length', minSize :0, maxSize :200 }, + { id:'proxy.host', type:'hostname' }, + { id:'proxy.port', type:'integer', minValue:21, maxValue:65535, empty:true }, + { id:'proxy.username', type:'length', minSize :0, maxSize :200 }, + { id:'proxy.password', type:'length', minSize :0, maxSize :200 }, { id:'removedMd.dir', type:'length', minSize :0, maxSize :200 }, - { id:'ldap.host', type:'length', minSize :1, maxSize :200 }, + { id:'ldap.host', type:'length', minSize :0, maxSize :200 }, { id:'ldap.host', type:'hostname' }, { id:'ldap.port', type:'integer', minValue:80, maxValue:65535, empty:true }, { id:'ldap.userDN', type:'length', minSize :1, maxSize :200 }, @@ -72,9 +74,11 @@ $('z3950.enable').checked = data['Z3950_ENABLE'] == 'true'; $('z3950.port') .value = data['Z3950_PORT']; - $('proxy.use') .checked = data['PROXY_USE'] == 'true'; - $('proxy.host').value = data['PROXY_HOST']; - $('proxy.port').value = data['PROXY_PORT']; + $('proxy.use') .checked = data['PROXY_USE'] == 'true'; + $('proxy.host').value = data['PROXY_HOST']; + $('proxy.port').value = data['PROXY_PORT']; + $('proxy.username').value = data['PROXY_USER']; + $('proxy.password').value = data['PROXY_PASS']; $('feedback.email') .value = data['FEEDBACK_EMAIL']; $('feedback.mail.host').value = data['FEEDBACK_MAIL_HOST']; @@ -126,6 +130,8 @@ PROXY_USE : $('proxy.use') .checked, PROXY_HOST : $('proxy.host').value, PROXY_PORT : $('proxy.port').value, + PROXY_USER : $('proxy.username').value, + PROXY_PASS : $('proxy.password').value, FEEDBACK_EMAIL : $('feedback.email') .value, FEEDBACK_MAIL_HOST : $('feedback.mail.host').value, Modified: trunk/web/geonetwork/xsl/config/config.xsl =================================================================== --- trunk/web/geonetwork/xsl/config/config.xsl 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/web/geonetwork/xsl/config/config.xsl 2007-08-30 11:42:08 UTC (rev 766) @@ -162,6 +162,16 @@ <td class="padded"><xsl:value-of select="/root/gui/config/port"/></td> <td class="padded"><input id="proxy.port" class="content" type="text" value="" size="20"/></td> </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/username"/></td> + <td class="padded"><input id="proxy.username" class="content" type="text" value="" size="20"/></td> + </tr> + + <tr> + <td class="padded"><xsl:value-of select="/root/gui/config/password"/></td> + <td class="padded"><input id="proxy.password" class="content" type="password" value="" size="20"/></td> + </tr> </table> </td> </tr> Modified: trunk/web/geonetwork/xsl/xml/config.xsl =================================================================== --- trunk/web/geonetwork/xsl/xml/config.xsl 2007-08-27 10:38:03 UTC (rev 765) +++ trunk/web/geonetwork/xsl/xml/config.xsl 2007-08-30 11:42:08 UTC (rev 766) @@ -44,6 +44,8 @@ <use><xsl:value-of select="$proxy/use/value"/></use> <host><xsl:value-of select="$proxy/host/value"/></host> <port><xsl:value-of select="$proxy/port/value"/></port> + <username><xsl:value-of select="$proxy/username/value"/></username> + <password><xsl:value-of select="$proxy/password/value"/></password> </proxy> <feedback> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-30 11:48:10
|
Revision: 769 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=769&view=rev Author: acarboni Date: 2007-08-30 04:47:54 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Updated Modified Paths: -------------- trunk/docs/changes.txt trunk/web/geonetwork/xml/schemas/iso19139/loc/en/labels.xml Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-08-30 11:47:17 UTC (rev 768) +++ trunk/docs/changes.txt 2007-08-30 11:47:54 UTC (rev 769) @@ -1,6 +1,6 @@ ================================================================================ === -=== GeoNetwork 2.1.0 RC2 : List of changes +=== GeoNetwork 2.1.0 final : List of changes === ================================================================================ @@ -15,6 +15,8 @@ - Intermap: added the AJAX advanced search. +- Added possibility to specify proxy's credentials + -------------------------------------------------------------------------------- --- Changes -------------------------------------------------------------------------------- @@ -33,6 +35,8 @@ - Intermap: removed many unused JS functions. +- Improved both admin's guide and server reference manuals. + -------------------------------------------------------------------------------- --- Bugs fixed -------------------------------------------------------------------------------- Modified: trunk/web/geonetwork/xml/schemas/iso19139/loc/en/labels.xml =================================================================== --- trunk/web/geonetwork/xml/schemas/iso19139/loc/en/labels.xml 2007-08-30 11:47:17 UTC (rev 768) +++ trunk/web/geonetwork/xml/schemas/iso19139/loc/en/labels.xml 2007-08-30 11:47:54 UTC (rev 769) @@ -1627,6 +1627,7 @@ search of available geographic data sets. Can be used to group keywords as well. Listed examples are not exhaustive. NOTE It is understood there are overlaps between general categories and the user is encouraged to select the one most appropriate.</description> + <condition>mandatory</condition> </element> <!-- ==================================================== --> <element name="gmd:MD_TopologyLevelCode"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-08-30 11:50:52
|
Revision: 771 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=771&view=rev Author: acarboni Date: 2007-08-30 04:50:49 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Changed version to 2.1.0 Modified Paths: -------------- trunk/docs/readme.html trunk/web/geonetwork/WEB-INF/server.prop Modified: trunk/docs/readme.html =================================================================== --- trunk/docs/readme.html 2007-08-30 11:48:41 UTC (rev 770) +++ trunk/docs/readme.html 2007-08-30 11:50:49 UTC (rev 771) @@ -9,7 +9,7 @@ </style></head> <body> - <div align="right"><span class="style1">GeoNetwork opensource V2.1.0 RC Date: 2007-08-19</span></div> + <div align="right"><span class="style1">GeoNetwork opensource V2.1.0 Date: 2007-08-30</span></div> <h1>GeoNetwork - Getting started</h1> <h2>Running the application</h2> Modified: trunk/web/geonetwork/WEB-INF/server.prop =================================================================== --- trunk/web/geonetwork/WEB-INF/server.prop 2007-08-30 11:48:41 UTC (rev 770) +++ trunk/web/geonetwork/WEB-INF/server.prop 2007-08-30 11:50:49 UTC (rev 771) @@ -1,8 +1,8 @@ # geonetwork version ### this is used to build the jar filename -release = 2.1.0-rc +release = 2.1.0 ### these are used by both gast and geonetwork at runtime version = 2.1.0 -subVersion = rc +subVersion = final This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fxp...@us...> - 2007-09-06 16:17:36
|
Revision: 788 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=788&view=rev Author: fxprunayre Date: 2007-09-06 09:17:35 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Added OpenSearch.org support Modified Paths: -------------- trunk/docs/changes.txt trunk/web/geonetwork/WEB-INF/config-portal.xml trunk/web/geonetwork/loc/en/xml/strings.xml trunk/web/geonetwork/loc/fr/xml/strings.xml trunk/web/geonetwork/xml/user-profiles.xml trunk/web/geonetwork/xsl/header.xsl Added Paths: ----------- trunk/web/geonetwork/xsl/opensearch.xsl Modified: trunk/docs/changes.txt =================================================================== --- trunk/docs/changes.txt 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/docs/changes.txt 2007-09-06 16:17:35 UTC (rev 788) @@ -3,6 +3,7 @@ === GeoNetwork 2.1.0 RC2 : List of changes === ================================================================================ +- Added portal.opensearch service to allow search from client supporting OpenSearch.org spec. - Added xml.region.get service to retrieve Bounding Box given a region id Modified: trunk/web/geonetwork/WEB-INF/config-portal.xml =================================================================== --- trunk/web/geonetwork/WEB-INF/config-portal.xml 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/web/geonetwork/WEB-INF/config-portal.xml 2007-09-06 16:17:35 UTC (rev 788) @@ -12,7 +12,14 @@ </class> <call name="sources" class=".guiservices.util.Sources"/> </service> - + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + <service name="portal.opensearch"> + <class name=".services.config.Get"/> + <output sheet="opensearch.xsl" contentType="text/xml; charset=UTF-8"/> + </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="portal.search.keywords"> Modified: trunk/web/geonetwork/loc/en/xml/strings.xml =================================================================== --- trunk/web/geonetwork/loc/en/xml/strings.xml 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/web/geonetwork/loc/en/xml/strings.xml 2007-09-06 16:17:35 UTC (rev 788) @@ -317,7 +317,8 @@ <noLogin>You are not logged in</noLogin> <northbc>North Bounding Coordinate</northbc> <online>Interactive map</online> - <onlink>Online Linkage</onlink> + <onlink>Online Linkage</onlink> + <opensearch>GeoNetwork opensearch service allow search to be made into the metadata catalog.</opensearch> <operation>Operation</operation> <organisation>Organisation / department</organisation> <paper>Hard copy</paper> Modified: trunk/web/geonetwork/loc/fr/xml/strings.xml =================================================================== --- trunk/web/geonetwork/loc/fr/xml/strings.xml 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/web/geonetwork/loc/fr/xml/strings.xml 2007-09-06 16:17:35 UTC (rev 788) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <strings> - + <opensearch>Service de recherche OpenSearch de GeoNetwork permettant la recherche de métadonnées dans le catalogue.</opensearch> <savexml> <dc>Télécharger les métadonnées au format Dublin Core</dc> <fgdc>Télécharger les métadonnées au format FGDC</fgdc> Modified: trunk/web/geonetwork/xml/user-profiles.xml =================================================================== --- trunk/web/geonetwork/xml/user-profiles.xml 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/web/geonetwork/xml/user-profiles.xml 2007-09-06 16:17:35 UTC (rev 788) @@ -227,7 +227,8 @@ <allow service="xml.region.get"/> <!-- Portal XML services --> - <allow service="portal.search"/> + <allow service="portal.search"/> + <allow service="portal.opensearch"/> <allow service="portal.search.keywords"/> <allow service="portal.search.present"/> <allow service="portal.present"/> Modified: trunk/web/geonetwork/xsl/header.xsl =================================================================== --- trunk/web/geonetwork/xsl/header.xsl 2007-09-06 16:11:42 UTC (rev 787) +++ trunk/web/geonetwork/xsl/header.xsl 2007-09-06 16:17:35 UTC (rev 788) @@ -15,6 +15,9 @@ <!-- Recent updates newsfeed --> <link href="{/root/gui/locService}/rss.latest" rel="alternate" type="application/rss+xml" title="GeoNetwork opensource | {/root/gui/strings/recentAdditions}" /> + <link href="{/root/gui/locService}/portal.opensearch" rel="search" type="application/opensearchdescription+xml"> + <xsl:attribute name="title">GeoNetwork|<xsl:value-of select="//site/organization"/>|<xsl:value-of select="//site/name"/></xsl:attribute> + </link> <!-- meta tags --> <xsl:copy-of select="/root/gui/strings/header_meta/meta"/> Added: trunk/web/geonetwork/xsl/opensearch.xsl =================================================================== --- trunk/web/geonetwork/xsl/opensearch.xsl (rev 0) +++ trunk/web/geonetwork/xsl/opensearch.xsl 2007-09-06 16:17:35 UTC (rev 788) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template match="/"> + <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> + <ShortName>GeoNetwork opensource | <xsl:value-of select="//site/organization"/> | <xsl:value-of select="//site/name"/></ShortName> + <Description><xsl:value-of select="/root/gui/strings/opensearch"/></Description> + <Tags>GeoNetwork Metadata ISO19115 ISO19139 DC FGDC</Tags> + <Contact><xsl:value-of select="//feedback/email"/></Contact> + <Url type="text/html"> + <xsl:attribute name="template"> + <xsl:value-of select="concat('http://',//server/host,':',//server/port,/root/gui/locService,'/rss.search?')"/> + <xsl:text>any={searchTerms}&</xsl:text> + </xsl:attribute> + </Url> + <Image height="16" width="16" type="image/vnd.microsoft.icon"> + <xsl:value-of select="concat('http://',//server/host,':',//server/port)"/> + <xsl:value-of select="/root/gui/url"/>/favicon.ico</Image> + </OpenSearchDescription> + </xsl:template> +</xsl:stylesheet> Property changes on: trunk/web/geonetwork/xsl/opensearch.xsl ___________________________________________________________________ Name: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-09-06 17:34:13
|
Revision: 789 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=789&view=rev Author: e_tajariol Date: 2007-09-06 10:34:11 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Improved PDF export: added scalebar, north arrow, copyright info and PDF metadata. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java trunk/src/org/wfp/vam/intermap/kernel/map/images/ImageMerger.java trunk/src/org/wfp/vam/intermap/kernel/map/mapServices/BoundingBox.java trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java trunk/web/intermap/WEB-INF/config.xml trunk/web/intermap/scripts/im_extras.js trunk/web/intermap/xsl/im_pdf_form.xsl Added Paths: ----------- trunk/src/org/wfp/vam/intermap/kernel/map/images/ScaleBar.java trunk/web/intermap/images/northarrow.png Modified: trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-06 17:34:11 UTC (rev 789) @@ -123,11 +123,13 @@ // htExpanded.remove(t); if (activeServiceId == id) - if (vRank.size() > 0) { + if (vRank.size() > 0) + { activeServiceId = vRank.get(0).intValue(); getService(activeServiceId).setActiveLayer(1); } - else { + else + { activeServiceId = -1; } } @@ -601,6 +603,8 @@ File output = GlobalTempFiles.getInstance().getFile(); String path = output.getPath(); // System.out.println("vTransparency" + vTransparency); // DEBUG + Collections.reverse(files); + Collections.reverse(vTransparency); ImageMerger.mergeAndSave(files, vTransparency, path, ImageMerger.GIF); imageName = output.getName(); imagePath = output.getPath(); Modified: trunk/src/org/wfp/vam/intermap/kernel/map/images/ImageMerger.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/images/ImageMerger.java 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/src/org/wfp/vam/intermap/kernel/map/images/ImageMerger.java 2007-09-06 17:34:11 UTC (rev 789) @@ -40,25 +40,31 @@ * Merge several images into one. The first file supplied will be put at top. * The destination image has the same size as the first input file. * - * @param inputFileNames - * is a Vector of Strings denoting path+filename of the input images + * @param images + * is a List of Images or Strings denoting the full path of the input image * @param outputFile * is a String denoting path+filename of the output image * @param format * is JPG or PNG as defined in the public constants. * */ - public static void mergeAndSave( - List inputFileNames, - List transparency, - String outputFile, - int format) { - BufferedImage bi = merge(inputFileNames, transparency); + public static void mergeAndSave( List images, + List<Float> transparency, + String outputFile, + int format) + { + BufferedImage bi = merge(images, transparency); + saveImage(bi, outputFile, format); + } - try { + public static void saveImage(BufferedImage bi, String outputFile, int format) + { + try + { OutputStream os = new FileOutputStream(outputFile); //format=2; // DEBUG - switch (format) { + switch (format) + { case JPG : encodeJPG(os, bi); @@ -69,46 +75,51 @@ break; case GIF : + encodeGIF(os, bi); + break; default : try { - encodeGIF(os, bi); + encodePNG(os, bi); break; } catch (IOException e) { - if (e.getMessage() == "too many colors for a GIF") - System.out.println("too many colors for a GIF, will try to generate JPG"); - else - System.out.println("error in encoding GIF file: " + e.getMessage() + "; will generate a JPG"); +// if (e.getMessage() == "too many colors for a GIF") +// System.out.println("too many colors for a GIF, will try to generate JPG"); +// else + System.out.println("error in encoding PNG file: " + e.getMessage() + "; will try to generate a JPG"); encodeJPG(os, bi); } } os.close(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - public static byte[] mergeB(Vector inputFileNames, Vector transparency) { - BufferedImage bi = merge(inputFileNames, transparency); + /** UNUSED */ +// public static byte[] mergeB(Vector inputFileNames, Vector transparency) { +// BufferedImage bi = merge(inputFileNames, transparency); +// +// try { +// ByteArrayOutputStream bos = new ByteArrayOutputStream(); +// encodeGIF(bos, bi); +// // encodePNG(bos, bi); +// // encodeJPG(bos, bi); +// byte[] out = bos.toByteArray(); +// bos.close(); +// return out; +// } catch (Exception e) { +// e.printStackTrace(); +// return null; +// } +// } - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - encodeGIF(bos, bi); - // encodePNG(bos, bi); - // encodeJPG(bos, bi); - byte[] out = bos.toByteArray(); - bos.close(); - return out; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - /** * Encodes the BufferedImage <I>bi</I> into the stream <I>os</I> as a JPG * @@ -204,45 +215,57 @@ } /** - * @param fileNames - * a Vector of String + * Merges the image listed in <I>images</I>, each with the related <I>transparency</I>. + * <I>images</I> items can be Images or String (representing the file path of the image). + * Images and Strings can also be mixed in the List. + * the higher in the image stack it will be printed. */ - public static BufferedImage merge(List fileNames, List transparency) { + public static BufferedImage merge(List images, List<Float> transparency) + { BufferedImage dest = null; Graphics2D destG = null; int rule; // This is SRC for the top image, and DST_OVER for the other ones float alpha; // This is 1.0 for the bottom image, and 0.9 for the other ones - for (int i = 0, size = fileNames.size(); i < size; i++) { - String filename = (String) fileNames.get(i); - Image image = new ImageIcon(filename).getImage(); + for (int i = 0, size = images.size(); i < size; i++) + { + Object o = images.get(i); + Image image; + if(o instanceof String) + { + String filename = (String)o; + image = new ImageIcon(filename).getImage(); + } + else if(o instanceof Image) + { + image = (Image)o; + } + else + throw new IllegalArgumentException(o + " is not an image"); - rule = AlphaComposite.DST_OVER; // Default value + rule = AlphaComposite.SRC_OVER; // Default value // Set alpha - alpha = ((Float) transparency.get(i)).floatValue(); - // alpha = 0.75F; // Boh? - // alpha = 0.9F; // Default value for a light transparence effect - // alpha = 1F; // Default value for solid colors + alpha = transparency.get(i).floatValue(); + // alpha = 0.9F; // Light transparence effect + // alpha = 1F; // Solid colors - if (i == 0) { + if (i == 0) + { //- init - dest = - new BufferedImage( - image.getWidth(null), - image.getHeight(null), - BufferedImage.TYPE_INT_ARGB); + dest = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); destG = dest.createGraphics(); //- values for top image rule = AlphaComposite.SRC; // Rule for 1st image } - if (i == size - 1) { - //- value for bottom image - alpha = 1F; - } +// if (i == size - 1) +// { +// //- value for bottom image +// alpha = 1F; +// } // System.out.println("i: " + i + "; alpha: " + alpha); // DEBUG destG.setComposite(AlphaComposite.getInstance(rule, alpha)); @@ -252,6 +275,51 @@ return dest; } + public static BufferedImage merge(String base, String over, int x, int y) + { + Image ibase = new ImageIcon(base).getImage(); + Image iover = new ImageIcon(over).getImage(); + return merge(ibase, iover, x, y); + } + + public static BufferedImage merge(String base, Image over, int x, int y) + { + Image ibase = new ImageIcon(base).getImage(); + return merge(ibase, over, x, y); + } + + public static BufferedImage merge(Image base, Image over, int x, int y) + { + float alpha = 1.0f; + + int bw = base.getWidth(null); + int bh = base.getHeight(null); + int ow = over.getWidth(null); + int oh = over.getHeight(null); + + BufferedImage dest = new BufferedImage(bw, bh, BufferedImage.TYPE_INT_ARGB); + Graphics2D destG = dest.createGraphics(); + + destG.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, alpha)); + destG.drawImage(base, 0, 0, null); + + System.out.println("Compositing images ("+ow+","+oh+") over ("+bw+","+bh+") @"+x+"+"+y); + + // negative position starts from lower right corner + if(x<0) + x = bw - ow + x; + + if(y<0) + y = bh - oh + y; + + System.out.println(" @"+x+"+"+y); + destG.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); + destG.drawImage(over, x, y, null); + + return dest; + } + + /** * You cannot convert to JPEG an image with an alpha channel. */ Added: trunk/src/org/wfp/vam/intermap/kernel/map/images/ScaleBar.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/images/ScaleBar.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/kernel/map/images/ScaleBar.java 2007-09-06 17:34:11 UTC (rev 789) @@ -0,0 +1,233 @@ + +package org.wfp.vam.intermap.kernel.map.images; + +import java.awt.*; + +import java.awt.image.BufferedImage; +import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; + +public class ScaleBar +{ + /** + * Build a scalebar image. + * + * @param lat the map latitude + * @param westBL the map westBL + * @param eastBL the map eastBL + * @param mapwidth the width of the map in pixel + * @param initscalewidth an approximative length in pixel of the scale bar. It will be increased to reach a nice number for the scale. + * + * @return The scalebar image + * + */ + static public BufferedImage getScaleBar(BoundingBox bb, int mapwidth, int initscalewidth) + { + double mapKMwidth = getMapLength(bb); + System.out.println("MAP LENGTH (" + bb + ") ---> " + mapKMwidth); + ScaleBarInfo sbw = getNormalizedScalebar(mapKMwidth, mapwidth, initscalewidth); + System.out.println("PREF SCALEBAR WDT " + initscalewidth + " --> " + sbw.px); + System.out.println("SCALEBAR "+ sbw.kmmant + "E" + sbw.kmexp); + String kmstr = getKMString(sbw.kmexp, sbw.kmmant); + + return buildScaleBarImage(sbw.px, kmstr); + } + + + /** + * Method getKMString + * + * @param kmexp an int + * @param p1 an int + * + * @return a String + */ + private static String getKMString(int exp, int mant) + { + StringBuffer sb = new StringBuffer(); + if(exp>=0) + { + sb.append(mant); + for (int i = 0; i < exp; i++) + sb.append("0"); + sb.append(" Km"); + } + else + { + sb.append("This map is really small!"); // FIXME + } + + return sb.toString(); + } + + /** + * Method getScalebarWidth + * + * @param mapKMwidth a double + * @param mapwidth an int + * @param initscalewidth an approximative length in pixel of the scale bar. It will be increased to reach a nice number for the scale. + * + * @return an int + */ + private static ScaleBarInfo getNormalizedScalebar(double mapKM, int mapPX, int prefSBpx) + { + double initsbw = mapKM/mapPX*prefSBpx; // length in km of the proposed scalebar width + System.out.println("SB proposed len KM " + initsbw); + + double[] norm = exp(initsbw); + int quant = (int)Math.ceil(norm[1]); + + int sbkm = (int)(quant * Math.pow(10.0, norm[0])); + int sbpx = (int)(mapPX * sbkm/mapKM); + + return new ScaleBarInfo((int)norm[0], quant, sbpx); + } + + static class ScaleBarInfo + { + int kmexp; + int kmmant; + int px; + + public ScaleBarInfo(int kmexp, int kmmant, int px) + { + this.kmexp = kmexp; + this.kmmant = kmmant; + this.px = px; + } + } + + /** + * Computes exponent and mantissa. + * + * @return a double[] {exp, mant} + */ + private static double[] exp(double mant) + { + if(mant<=0) + throw new IllegalArgumentException(""+mant); + + double exp = 0; + + if(mant > 1) + while(mant > 10) + { + exp++; + mant/=10; + } + else + while(mant < 1) + { + exp--; + mant*=10; + } + + return new double[]{exp, mant}; + } + + /** + * Great Circle Distances + * The great circle distance between two points is often difficult to measure on a globe and, + * in general, cannot be measured accurately on a map due to distortion introduced in representing + * the approximately spherical geometry of the Earth on a flat map. + * However, great circle distances can be calculated easily + * given the latitudes and longitudes of the two points, + * using the following formula from spherical trigonometry: + * + * cos D = ( sin a )(sin b) + (cos a)(cos b)(cos P) + * + * where: + * + * D is the angular distance between points A and B + * a is the latitude of point A + * b is the latitude of point B + * P is the longitudinal difference between points A and B + * + * In applying the above formula, south latitudes and west longitudes + * are treated as negative angles. Once cos D has been calculated, + * the angle D can be determined using the ARCOS function. + * + * The distance in km is obtained by multiplying the angle D in degrees by 111 km + * + * @param lat a float + * @param westBL a float + * @param eastBL a float + * + * @return the lenght between the two points in kilometers + */ + private static double getMapLength(BoundingBox bb) + { + float lat; + + if(bb.getNorth()*bb.getSouth() < 0) + lat = 0; // take the equator when it is inside the map + else + lat = Math.min(Math.abs(bb.getNorth()), Math.abs(bb.getSouth())); // take the more meaningful one + + double sina = Math.sin(Math.toRadians(lat)); + double cosa = Math.cos(Math.toRadians(lat)); + double cosd = sina*sina + cosa*cosa*Math.cos(Math.toRadians(bb.getLongDiff())); + double d = Math.acos(cosd); + System.out.print(" --- SIN(LAT="+lat+")="+sina); + System.out.print(" --- COS(LAT="+lat+")="+cosa); + System.out.println(" --- COSD="+cosd); + return Math.toDegrees(d) *111; + } + + + /** + * Build the image + * + * @param px an int + * @param kmstr a String + * + * @return a BufferedImage + */ + private static BufferedImage buildScaleBarImage(int px, String text) + { + Font font = new Font("helvetica", Font.PLAIN, 15); + Color bg = Color.WHITE; + Color fg = Color.BLACK; + int paddingleft = 5; + int paddingbottom = 5; + int dist = 3; + int sbheight = 10; + + FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font); + int fw = fm.stringWidth(text) + 4; + int fh = fm.getHeight() + 2 ; + + int width = paddingleft + Math.max(fw , px) ; + int height = fh + dist + sbheight + paddingbottom; + +//System.out.println("Creating label image '"+text+"' "+w+"x"+h); + + BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = img.createGraphics(); + + g2d.setFont(font); + g2d.setColor(bg); + // paddingleft + shadow + offset + g2d.drawString(text, paddingleft +1 +0, fm.getAscent() -1 ); + g2d.drawString(text, paddingleft +1 +1, fm.getAscent() -1 ); + g2d.drawString(text, paddingleft +1 +1, fm.getAscent() -0 ); + g2d.drawString(text, paddingleft +1 +1, fm.getAscent() +1 ); + g2d.drawString(text, paddingleft +1 +0, fm.getAscent() +1 ); + g2d.drawString(text, paddingleft +1 -1, fm.getAscent() +1 ); + g2d.drawString(text, paddingleft +1 -1, fm.getAscent() -0 ); + g2d.drawString(text, paddingleft +1 -1, fm.getAscent() -1 ); + + g2d.setColor(fg); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.drawString(text, paddingleft +1 , fm.getAscent() ); + + g2d.setColor(bg); + g2d.fillRect(paddingleft, fh + dist -1, px+2, sbheight+2); + + g2d.setColor(fg); + g2d.fillRect(paddingleft+1, fh + dist , px, sbheight); + + return img; + } + + +} Modified: trunk/src/org/wfp/vam/intermap/kernel/map/mapServices/BoundingBox.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/mapServices/BoundingBox.java 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/src/org/wfp/vam/intermap/kernel/map/mapServices/BoundingBox.java 2007-09-06 17:34:11 UTC (rev 789) @@ -58,6 +58,8 @@ public float getWest() { return westBound; } + public float getLongDiff() { return eastBound - westBound;} + /** * Centers the BoundingBox to the specified coordinates. * If the resulting coordinates are not valid, moves to the Modified: trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/src/org/wfp/vam/intermap/services/export/ExportPDF.java 2007-09-06 17:34:11 UTC (rev 789) @@ -2,11 +2,12 @@ package org.wfp.vam.intermap.services.export; + import com.lowagie.text.*; +import com.lowagie.text.pdf.*; -import com.lowagie.text.pdf.PdfPCell; -import com.lowagie.text.pdf.PdfPTable; -import com.lowagie.text.pdf.PdfWriter; +import java.awt.Color; +import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.util.HashMap; @@ -17,14 +18,24 @@ import org.jdom.Element; import org.wfp.vam.intermap.kernel.GlobalTempFiles; import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.kernel.map.images.ImageMerger; +import org.wfp.vam.intermap.kernel.map.images.ScaleBar; import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; import org.wfp.vam.intermap.services.map.MapUtil; import org.wfp.vam.intermap.util.Util; public class ExportPDF implements Service { - public void init(String appPath, ServiceConfig config) throws Exception {} + private final static int MAP_WIDTH_PX = 1160; + private final static int MAP_HEIGHT_PX = 870; + private String _northarrowfile; + + public void init(String appPath, ServiceConfig config) throws Exception + { + _northarrowfile = config.getMandatoryValue("northArrowImage"); + } + public Element exec(Element params, ServiceContext context) throws Exception { MapMerger mm = MapUtil.getMapMerger(context); @@ -38,59 +49,75 @@ if( bb != null) mm.setBoundingBox(bb); - String imagename = mm.merge(1160, 870); - File imagepath = mm.getImageLocalPath(); + String title = params.getChildText("title"); + String copyright = params.getChildText("copyright"); + boolean drawScale = "on".equals(params.getChildText("scalebar")); + boolean drawArrow = "on".equals(params.getChildText("arrow")); + boolean showLayerList = "on".equals(params.getChildText("layerlist")); + boolean showDetails = "on".equals(params.getChildText("details")); + Document document = new Document(pagesize); + + File pdfFile = GlobalTempFiles.getInstance().getFile(".pdf"); + PdfWriter pw = PdfWriter.getInstance(document, new FileOutputStream(pdfFile)); + + document.addTitle(title!=null? title: "Geonetwork Map"); + document.addSubject(""); document.addCreator("Geonetwork Intermap"); - document.addTitle("Geonetwork Map"); document.addCreationDate(); + document.addAuthor("ETj"); + document.addProducer(); + document.addKeywords(getKeywords(mm)); + if(copyright!=null) + document.addHeader("Copyright note", copyright); - File pdfFile = GlobalTempFiles.getInstance().getFile(".pdf"); - PdfWriter pw = PdfWriter.getInstance(document, new FileOutputStream(pdfFile)); + if(copyright != null) + pw.setPageEvent(new PE(copyright)); + document.open(); - // Add image - Image image = Image.getInstance(imagepath.getAbsolutePath()+File.separator+imagename); - image.scaleToFit(500,400); - image.setAlignment(Image.MIDDLE); - document.add(image); + // TITLE + if( title != null) + { + Font font = new Font(Font.HELVETICA, 20, Font.NORMAL); + Paragraph para = new Paragraph(title, font); + para.setAlignment(Paragraph.ALIGN_CENTER); + document.add(para); + } - if(params.getChildText("layerlist") != null) // the user wants the layer list + // IMAGE + String map = mm.merge(MAP_WIDTH_PX, MAP_HEIGHT_PX); + String mapImageFullPath = mm.getImageLocalPath().getAbsolutePath() + File.separatorChar + map; + + if(drawArrow) { - document.add(new Paragraph("Layers list:")); + BufferedImage merged = ImageMerger.merge(mapImageFullPath, _northarrowfile, -5, 5); + mapImageFullPath = GlobalTempFiles.getInstance().getFile().getPath(); // we need a new file: MapMerger could reuse its own file + ImageMerger.saveImage(merged, mapImageFullPath, ImageMerger.PNG); + } + + if(drawScale) + { + BufferedImage sb = ScaleBar.getScaleBar(mm.getBoundingBox(), MAP_WIDTH_PX, 150); + BufferedImage merged = ImageMerger.merge(mapImageFullPath, sb, 5, -5); + mapImageFullPath = GlobalTempFiles.getInstance().getFile().getPath(); // we need a new file: drawArrow may be not requested + ImageMerger.saveImage(merged, mapImageFullPath, ImageMerger.PNG); + } + + Image mapImage = Image.getInstance(mapImageFullPath); + mapImage.scaleToFit(500,400); + mapImage.setAlignment(Image.MIDDLE); + document.add(mapImage); + + if(showLayerList) + { + document.add(new Paragraph("Layers list:")); // FIXME: i18n me! List llist = new List(true, 20); for (int i = 0; i < mm.size(); i++) { - ListItem litem = new ListItem(); - - // Add layer name - String servicename = mm.getServiceRanked(i).getName(); - Chunk name = new Chunk(servicename); - if( ! mm.isVisibleRanked(i) ) - { - System.out.println("Service " + servicename + " is hidden"); - Font font = new Font(); - font.setStyle(Font.STRIKETHRU); - name.setFont(font); - } - litem.add(name); - - if(params.getChildText("details") != null) // the user wants details - { - // Add transparency info - Font font = new Font(); - font.setSize(Font.DEFAULTSIZE*0.8f); - font.setStyle(Font.ITALIC); - int trasp = mm.getLayerTransparencyRanked(i); - if(trasp != 100) - { - Chunk transp = new Chunk( " (" + mm.getLayerTransparencyRanked(i)+"%)", font); - litem.add(transp); - } - } - + ListItem litem = getLayerPara(mm, i, showDetails); llist.add(litem); } @@ -99,7 +126,7 @@ if(params.getChildText("boundingbox") != null) // the user wants the bbox { - // Be careful: the requested bbox may be reaspected to respect image dimensions + // Be careful: the requested bbox may have been reaspected to keep the image dimensions ratio // Let's say we'll print the reaspected bbox PdfPTable t = getBBTable(mm.getBoundingBox()); @@ -114,8 +141,57 @@ .addContent(new Element("url").setText(MapUtil.getTempUrl() + "/" + pdfFile.getName()))); } - private PdfPTable getBBTable(BoundingBox bb) + private ListItem getLayerPara(MapMerger mm, int layerRank, boolean showDetails) { + ListItem litem = new ListItem(); + + // Add layer name + String servicename = mm.getServiceRanked(layerRank).getName(); + Chunk name = new Chunk(servicename); + + if( ! mm.isVisibleRanked(layerRank) ) + { + Font font = new Font(); + font.setStyle(Font.STRIKETHRU); + name.setFont(font); + } + litem.add(name); + + if(showDetails) // the user wants details + { + // Add transparency info + Font font = new Font(); + font.setSize(Font.DEFAULTSIZE*0.8f); + font.setStyle(Font.ITALIC); + int trasp = mm.getLayerTransparencyRanked(layerRank); + if(trasp != 100) + { + Chunk transp = new Chunk( " (" + mm.getLayerTransparencyRanked(layerRank)+"%)", font); + litem.add(transp); + } + } + return litem; + } + + private String getKeywords(MapMerger mm) + { + StringBuffer sb = new StringBuffer("Geonetwork, Intermap"); + + for (int layerRank = 0; layerRank < mm.size(); layerRank++) + { + if( mm.isVisibleRanked(layerRank) ) + { + String servicename = mm.getServiceRanked(layerRank).getName(); + sb.append(", ").append(servicename); + } + } + + return sb.toString(); + } + + + private static PdfPTable getBBTable(BoundingBox bb) + { PdfPTable t = new PdfPTable(3); PdfPCell empty = new PdfPCell(new Paragraph("")); @@ -166,6 +242,7 @@ PAGESIZE.put("a3", PageSize.A3); PAGESIZE.put("letter", PageSize.LETTER); PAGESIZE.put("legal", PageSize.LEGAL); + // This list may be extended with other pagesize values } private Rectangle parsePagesize(String ps) @@ -177,66 +254,70 @@ return ret; } -// public static void main(String[] args) throws DocumentException, FileNotFoundException, IOException, BadElementException -// { -// Document document = new Document(PageSize.A4); -// -// PdfWriter pw = PdfWriter.getInstance(document, new FileOutputStream("/tmp/my.pdf")); -// -// document.addCreator("Geonetwork Intermap"); -// document.addTitle("Geonetwork Map"); -// document.addCreationDate(); -// -// document.open(); -// document.add(new Paragraph("This is a paragraph")); -// Image image = Image.getInstance(new URL("file:///tmp/1160x870.gif")); -// System.out.println("XDPI="+image.getDpiX()); -// System.out.println("YDPI="+image.getDpiY()); -// -// image.scaleToFit(500,400); -// image.setAlignment(Image.MIDDLE); -// System.out.println("XDPI="+image.getDpiX()); -// System.out.println("YDPI="+image.getDpiY()); -// document.add(image); -// -// PdfPTable t = new PdfPTable(3); -// -// PdfPCell empty = new PdfPCell(new Paragraph("")); -// empty.setBorder(0); -// -// PdfPCell n = new PdfPCell(new Paragraph("N: 123.456")); -// n.setVerticalAlignment(Cell.ALIGN_MIDDLE); -// n.setHorizontalAlignment(Cell.ALIGN_CENTER); -//// n.set -// PdfPCell e = new PdfPCell(new Paragraph("E: 23.56")); -// e.setVerticalAlignment(Cell.ALIGN_MIDDLE); -// e.setHorizontalAlignment(Cell.ALIGN_LEFT); -// PdfPCell w = new PdfPCell(new Paragraph("W: -23.56")); -// w.setVerticalAlignment(Cell.ALIGN_MIDDLE); -// w.setHorizontalAlignment(Cell.ALIGN_RIGHT); -// PdfPCell s = new PdfPCell(new Paragraph("S: 123.456")); -// s.setVerticalAlignment(Cell.ALIGN_MIDDLE); -// s.setHorizontalAlignment(Cell.ALIGN_CENTER); -// -// -// t.addCell(new PdfPCell(empty)); -// t.addCell(n); -// t.addCell(new PdfPCell(empty)); -// -// t.addCell(w); -// t.addCell(new PdfPCell(empty)); -// t.addCell(e); -// -// t.addCell(new PdfPCell(empty)); -// t.addCell(s); -// t.addCell(new PdfPCell(empty)); -// -// document.add(t); -// -// document.close(); -// -// } + static class PE extends PdfPageEventHelper + { + protected PdfTemplate total; + protected BaseFont _watermarkFont; + protected PdfGState gstate; + protected Phrase footer; + protected String _watermarkText; + + public PE(String watermark) + { + this._watermarkText = watermark; + + footer = new Phrase(watermark); + Font font = new Font(); + font.setSize(Font.DEFAULTSIZE * 0.9f); + font.setStyle(Font.ITALIC); + footer.setFont(font); + } + + public void onOpenDocument(PdfWriter writer, Document document) + { + total = writer.getDirectContent().createTemplate(100, 100); + total.setBoundingBox(new Rectangle(-20, -20, 100, 100)); + + try + { + _watermarkFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); + } + catch (Exception e) + { + throw new ExceptionConverter(e); + } + + gstate = new PdfGState(); + gstate.setFillOpacity(0.3f); + gstate.setStrokeOpacity(0.3f); + } + + public void onEndPage(PdfWriter writer, Document document) + { + // Draw watermark + PdfContentByte contentunder = writer.getDirectContent(); + contentunder.saveState(); + contentunder.setGState(gstate); + contentunder.setColorFill(Color.blue); + contentunder.beginText(); + contentunder.setFontAndSize(_watermarkFont, 48); + contentunder.showTextAligned(com.lowagie.text.Element.ALIGN_CENTER, + _watermarkText, + document.getPageSize().getWidth() / 2, + document.getPageSize().getHeight() / 2, 45); + contentunder.endText(); + contentunder.restoreState(); + + // Draw footer + PdfContentByte cb = writer.getDirectContent(); + ColumnText.showTextAligned(cb, + com.lowagie.text.Element.ALIGN_CENTER, + footer, + (document.right() - document.left()) / 2 + document.leftMargin(), + document.bottom() - 10, 0); + } + } + } - Modified: trunk/web/intermap/WEB-INF/config.xml =================================================================== --- trunk/web/intermap/WEB-INF/config.xml 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/web/intermap/WEB-INF/config.xml 2007-09-06 17:34:11 UTC (rev 789) @@ -83,7 +83,7 @@ <param name="httpCacheDir" value="../web/intermap/httpCache/" /> <param name="httpCacheDeleteEvery" value="60" /> <param name="useCache" value="true" /> - + </appHandler> <!-- ====================================================================== --> @@ -522,7 +522,9 @@ </service> <service name="create.pdf"> - <class name=".services.export.ExportPDF"/> + <class name=".services.export.ExportPDF"> + <param name="northArrowImage" value="../web/intermap/images/northarrow.png" /> + </class> </service> Added: trunk/web/intermap/images/northarrow.png =================================================================== (Binary files differ) Property changes on: trunk/web/intermap/images/northarrow.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/web/intermap/scripts/im_extras.js =================================================================== --- trunk/web/intermap/scripts/im_extras.js 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/web/intermap/scripts/im_extras.js 2007-09-06 17:34:11 UTC (rev 789) @@ -218,66 +218,85 @@ */ function im_openPDFform() { - // setup WB - clearNode('im_whiteboard'); - var WB = $('im_whiteboard'); + // setup WB + clearNode('im_whiteboard'); + var WB = $('im_whiteboard'); + + var wbtitle = im_createWBTitle("Export this map as PDF"); //FIXME i18n + WB.appendChild(wbtitle); + + var closer = im_getWBCloser(); + WB.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + var div = document.createElement('div'); // main box + div.id = "im_createPDF"; + div.className = 'im_wbcontent'; + WB.appendChild(div); + + var myAjax = new Ajax.Updater ( + 'im_createPDF', + '/intermap/srv/en/static.form.pdf', + { + method: 'get', + onFailure: im_load_error + } + ); - var wbtitle = im_createWBTitle("Export this map as PDF"); //FIXME i18n - WB.appendChild(wbtitle); - - var closer = im_getWBCloser(); - WB.appendChild(closer); - Event.observe(closer, 'click', im_closeWhiteBoard); - - var div = document.createElement('div'); // main box - div.id = "im_createPDF"; - div.className = 'im_wbcontent'; - WB.appendChild(div); - - var myAjax = new Ajax.Updater ( - 'im_createPDF', - '/intermap/srv/en/static.form.pdf', - { - method: 'get', - onFailure: im_load_error - } - ); - } function im_requestPDF() { - var orient = $('pdf_orientation').value; - var psize = $('pdf_pagesize').value; - var bllist = $('pdf_layerlist').checked; - var bdetails = $('pdf_details').checked; - var bbbox = $('pdf_boundingbox').checked; - - var pars = "orientation="+orient+ - "&pagesize="+psize+ - "&"+im_bm_getURLbbox(); - if(bllist) - pars += "&layerlist=on"; - - if(bdetails) - pars += "&details=on"; + var orient = $('pdf_orientation').value; + var psize = $('pdf_pagesize').value; - if(bbbox) - pars += "&boundingbox=on"; - - $('im_requestingpdf').show(); - $('im_requestpdf').hide(); - $('im_builtpdf').hide(); - - var myAjax = new Ajax.Request ( - '/intermap/srv/en/create.pdf', - { - method: 'get', - parameters: pars, - onSuccess: im_openPDF, - onFailure: im_load_error - } - ); + var ptitle = $('pdf_title').value; + var pcopy = $('pdf_copyright').value; + + var bllist = $('pdf_layerlist').checked; + var bdetails = $('pdf_details').checked; + var bbbox = $('pdf_boundingbox').checked; + var bscale = $('pdf_scalebar').checked; + var barrow = $('pdf_arrow').checked; + + var pars = "orientation="+orient+ + "&pagesize="+psize+ + "&"+im_bm_getURLbbox(); + + if(ptitle) + pars += "&title="+ encodeURIComponent(ptitle); + if(pcopy) + pars += "©right="+ encodeURIComponent(pcopy); + + + if(bllist) + pars += "&layerlist=on"; + + if(bdetails) + pars += "&details=on"; + + if(bbbox) + pars += "&boundingbox=on"; + + if(bscale) + pars += "&scalebar=on"; + + if(barrow) + pars += "&arrow=on"; + + $('im_requestingpdf').show(); + $('im_requestpdf').hide(); + $('im_builtpdf').hide(); + + var myAjax = new Ajax.Request ( + '/intermap/srv/en/create.pdf', + { + method: 'get', + parameters: pars, + onSuccess: im_openPDF, + onFailure: im_load_error + } + ); } Modified: trunk/web/intermap/xsl/im_pdf_form.xsl =================================================================== --- trunk/web/intermap/xsl/im_pdf_form.xsl 2007-09-06 16:17:35 UTC (rev 788) +++ trunk/web/intermap/xsl/im_pdf_form.xsl 2007-09-06 17:34:11 UTC (rev 789) @@ -5,6 +5,10 @@ <xsl:template match="/"> <div> + Title: + <input type="text" name="pdf_title" id="pdf_title" width="100%"></input> + <br/> + Page size: <select id="pdf_pagesize"> <option value="A4">A4</option> @@ -19,19 +23,27 @@ </select> <br/> -<!-- <input type="radio" name="orientation" value="portrait">Portrait</input> - <input type="radio" name="orientation" value="landscape">Landscape</input> - <br/> ---> <input type="checkbox" name="pdf_layerlist" id="pdf_layerlist" checked="true">Print layerlist</input> <br/> - <input type="checkbox" name="pdf_details" id="pdf_details">Print details</input> + <input type="checkbox" name="pdf_details" id="pdf_details" >Print details</input> +<!-- onselect="javascript: alert($('pdf_layerlist').checked); if($('pdf_layerlist').checked ) $('pdf_details').show(); else $('pdf_details').hide();" --> <br/> <input type="checkbox" name="pdf_boundingbox" id="pdf_boundingbox">Print bounding box</input> <br/> + + <input type="checkbox" name="pdf_arrow" id="pdf_arrow">North arrow</input> + <br/> + + <input type="checkbox" name="pdf_scalebar" id="pdf_scalebar">Scale</input> + <br/> + + Copyright info: + <input type="text" name="pdf_copyright" id="pdf_copyright"></input> + <br/> + <br/> <div id="im_requestpdf"> <button onClick="javascript:im_requestPDF();">Generate PDF</button> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-09-15 15:26:37
|
Revision: 825 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=825&view=rev Author: e_tajariol Date: 2007-09-15 08:25:17 -0700 (Sat, 15 Sep 2007) Log Message: ----------- Map can now be zoomed to a specified scale. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java trunk/src/org/wfp/vam/intermap/services/map/MapUtil.java trunk/web/intermap/WEB-INF/config.xml trunk/web/intermap/scripts/im_ajax.js trunk/web/intermap/scripts/im_bigmap.js trunk/web/intermap/xml/user-profiles.xml trunk/web/intermap/xsl/index-embedded.xsl Added Paths: ----------- trunk/src/org/wfp/vam/intermap/kernel/map/Layer.java trunk/src/org/wfp/vam/intermap/services/map/SetScale.java Added: trunk/src/org/wfp/vam/intermap/kernel/map/Layer.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/Layer.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/kernel/map/Layer.java 2007-09-15 15:25:17 UTC (rev 825) @@ -0,0 +1,37 @@ +/** + * Layer.java + * + * @author Created by ETj + */ + +package org.wfp.vam.intermap.kernel.map; + +import org.wfp.vam.intermap.kernel.map.mapServices.MapService; + +public class Layer +{ + private final MapService _service; + private float _transparency = 1.0F; + private boolean _expanded = true; // Used for ARCims services only + private boolean _visible = true; + + public Layer(MapService service) + { + _service = service; + } + +// public void setService(MapService service){_service = service;} + public MapService getService(){return _service;} + + public void setTransparency(float transparency){_transparency = transparency;} + public float getTransparency(){return _transparency;} + public int getIntTransparency(){return (int)(_transparency * 100);} + + // Used for ARCims services only + public void setExpanded(boolean isExpanded){_expanded = isExpanded;} + public boolean isExpanded(){return _expanded;} + + public void setVisible(boolean isVisibile){_visible = isVisibile;} + public boolean isVisible(){return _visible;} +} + Modified: trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-15 15:25:17 UTC (rev 825) @@ -3,7 +3,7 @@ * to add / remove services, and to set and change the bounding box. * * @author Stefano Giaccio, Emanuele Tajariol - + * */ package org.wfp.vam.intermap.kernel.map; @@ -20,7 +20,6 @@ import org.wfp.vam.intermap.http.ConcurrentHTTPTransactionHandler; import org.wfp.vam.intermap.http.cache.HttpGetFileCache; import org.wfp.vam.intermap.kernel.GlobalTempFiles; -import org.wfp.vam.intermap.kernel.TempFiles; import org.wfp.vam.intermap.kernel.map.images.ImageMerger; import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; import org.wfp.vam.intermap.kernel.map.mapServices.HttpClient; @@ -31,7 +30,7 @@ public class MapMerger { private static HttpGetFileCache cache; - private static int dpi = 96; + private static float dpi = 96; private BoundingBox bBox = new BoundingBox(); // Image extent @@ -45,7 +44,7 @@ private String imagePath = null; // The path of the merge image file private float degScale; // The map scale private float distScale; // The map scale - private Hashtable htErrors = new Hashtable(); + private Map<Integer,String> htErrors = new Hashtable<Integer,String>(); private boolean reaspectWms = true; public static void setCache(HttpGetFileCache cache) { @@ -54,6 +53,10 @@ public static void setDpi(int dpi) { MapMerger.dpi = dpi; } + public static float getDpi() + { + return dpi; + } public void reaspectWms(boolean reaspect) { this.reaspectWms = reaspect; }; @@ -92,7 +95,6 @@ * */ public int addService(MapService service) { // System.out.println("service: " + service); // DEBUG -// if (htServices.size() == 0) activeServiceId = nextId; if ( _layers.isEmpty() ) activeServiceId = nextId; Integer id = new Integer(nextId++); @@ -100,10 +102,6 @@ Layer layer = new Layer(service); _layers.put(id, layer); -// htServices.put(id, service); -// htTransparency.put(id, new Float(1.0)); -// htExpanded.put(id, new Boolean(true)); -// htShow.put(id, new Boolean(true)); vRank.add(0, id); return id.intValue(); @@ -117,11 +115,6 @@ _layers.remove(id); vRank.remove(new Integer(id)); // be careful: we're removing the id object (Integer); an int would be used as index -// Integer t = new Integer(id); -// htServices.remove(t); -// htTransparency.remove(t); -// htExpanded.remove(t); - if (activeServiceId == id) if (vRank.size() > 0) { @@ -135,7 +128,8 @@ } /** Moves a service up */ - public void moveServiceUp(int id) { + public void moveServiceUp(int id) + { Integer t = new Integer(id); int pos = vRank.indexOf(t); if (pos > 0) { @@ -145,7 +139,8 @@ } /** Moves a service down */ - public void moveServiceDown(int id) { + public void moveServiceDown(int id) + { Integer t = new Integer(id); int pos = vRank.indexOf(t); if (pos < vRank.size() - 1) { @@ -164,15 +159,12 @@ Element elServices = new Element("services"); // Add each contained service to the elServices, ordered by vRank -// for (int i = 0; i < vRank.size(); i++) { - for (int rank: vRank) { -// MapService s = (MapService)htServices.get(vRank.get(i)); - Layer layer = _layers.get(rank); + for (int idx: vRank) { + Layer layer = _layers.get(idx); MapService s = layer.getService(); elServices.addContent(new Element("layer") -// .setAttribute("id", vRank.get(i) + "") - .setAttribute("id", rank + "") + .setAttribute("id", idx + "") .setAttribute("title", "" + s.getTitle()) .setAttribute("type", "" + s.getType()) .setAttribute("transparency", "" + layer.getIntTransparency()) @@ -193,11 +185,11 @@ // elServices.addContent(s.toElement() // .setAttribute("id", vRank.get(i) + "")); // } - for (int rank: vRank) + for (int id: vRank) { - MapService s = _layers.get(rank).getService(); + MapService s = _layers.get(id).getService(); elServices.addContent(s.toElement() - .setAttribute("id", rank + "")); + .setAttribute("id", id + "")); } @@ -215,36 +207,31 @@ return elServices; } -// public Iterable<Layer> getLayers() -// { -// return new Iterable<Layer>() -// { -// public Iterator<Layer> iterator() -// { -// return new Iterator<Layer>() -// { -// private int i = 0; -// private int last = vRank.size(); -// -// public boolean hasNext() { return i<last; } -// public Layer next() { return _layers.get(vRank.get(i++)); } -// public void remove() { throw new UnsupportedOperationException();} -// }; -// } -// }; -// } + public Iterable<Layer> getLayers() + { + return new Iterable<Layer>() + { + public Iterator<Layer> iterator() + { + return new Iterator<Layer>() + { + private int i = 0; + private int last = vRank.size(); + public boolean hasNext() { return i<last; } + public Layer next() { return _layers.get(vRank.get(i++)); } + public void remove() { throw new UnsupportedOperationException();} + }; + } + }; + } + + /** Returns an Element containing the transparency value for each service */ - public Element getStructTransparencies() { + public Element getStructTransparencies() + { Element elTransparency = new Element("transparency"); -// for (Enumeration e = htServices.keys(); e.hasMoreElements(); ) { -// Integer serviceId = (Integer)e.nextElement(); -// int f = (int)(((Float)htTransparency.get(serviceId)).floatValue() * 100); -// elTransparency.addContent( new Element("service").setAttribute("id", serviceId.toString()) -// .setAttribute("transparency", f + "") -// .setAttribute("name", ((MapService)htServices.get(serviceId)).getName()) ); -// } for(Integer id: _layers.keySet()) { @@ -260,22 +247,19 @@ } /** Returns the transparency of a given layer */ -// public float getLayerTransparency(int id) { -// Integer serviceId = new Integer(id); -// return (int)(((Float)htTransparency.get(serviceId)).floatValue() * 100); - public int getLayerTransparency(int id) { + public int getLayerTransparency(int id) + { return _layers.get(id).getIntTransparency(); } - public int getLayerTransparencyRanked(int id) { + + public int getLayerTransparencyRanked(int id) + { return _layers.get(vRank.get(id)).getIntTransparency(); } /** Sets the transparency value for a given service */ - public void setTransparency(int id, float transparency) throws Exception { -// if (htServices.get(new Integer(id)) == null) -// throw new Exception("Illegal service id"); -// -// htTransparency.put(new Integer(id), new Float(transparency)); + public void setTransparency(int id, float transparency) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); @@ -283,8 +267,8 @@ } /** Expands a service in the layer frame (used for ArcIMS services only) */ - public void expandService(int id) throws Exception { -// htExpanded.put(new Integer(id), new Boolean(true)); + public void expandService(int id) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); @@ -292,7 +276,8 @@ } /** Collapses a service in the layer frame (used for ArcIMS services only) */ - public void collapseService(int id) throws Exception { + public void collapseService(int id) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); @@ -301,46 +286,44 @@ /** ??? Expands a service in the layer frame (used for ArcIMS services only) */ - public void showService(int id) throws Exception { + public void showService(int id) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); _layers.get(id).setVisible(true); -// htShow.put(new Integer(id), new Boolean(true)); } /** ??? Collapses a service in the layer frame (used for ArcIMS services only) */ - public void hideService(int id) throws Exception { + public void hideService(int id) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); _layers.get(id).setVisible(false); -// htShow.put(new Integer(id), new Boolean(false)); } - public boolean toggleVisibility(int id) throws Exception { + public boolean toggleVisibility(int id) throws Exception + { if ( ! _layers.containsKey(id)) throw new Exception("Illegal service id"); boolean newVis = ! _layers.get(id).isVisible(); _layers.get(id).setVisible(newVis); return newVis; - -// Boolean bVisibility = (Boolean)htShow.get(new Integer(id)); -// -// boolean newVisibility = !bVisibility.booleanValue(); -// htShow.put(new Integer(id), new Boolean(newVisibility)); -// return newVisibility; } /** Get error messages from the remote servers */ - public Element getErrors() { + public Element getErrors() + { Element errors = new Element("errors"); - for (Enumeration e = htErrors.keys(); e.hasMoreElements(); ) { - Integer id = (Integer)e.nextElement(); - errors.addContent( new Element("layer") - .setAttribute("id", id.toString()) - .setAttribute("message", (String)htErrors.get(id)) ); + + for(Integer id: htErrors.keySet() ) + { + errors.addContent( + new Element("layer") + .setAttribute("id", id.toString()) + .setAttribute("message", htErrors.get(id)) ); } return errors; @@ -364,32 +347,22 @@ public MapService next() { return _layerIterator.next().getService(); } public void remove() { throw new UnsupportedOperationException();} }; - } }; -// return htServices.elements(); } /** Returns the MapService element with the given id*/ public MapService getService(int id) { return _layers.get(id).getService(); } - public MapService getServiceRanked(int id) { return _layers.get(vRank.get(id)).getService(); } + public MapService getServiceRanked(int rank) { return _layers.get(vRank.get(rank)).getService(); } // public MapService getService(int id) { return (MapService)htServices.get(new Integer(id)); } // public boolean isVisible(int id) { return _layers.get(id).isVisible(); } - public boolean isVisibleRanked(int id) { return _layers.get(vRank.get(id)).isVisible(); } + public boolean isVisibleRanked(int rank) { return _layers.get(vRank.get(rank)).isVisible(); } /** Returns an element containing informations about the expanded or collapsed * services */ private Element getStructExpanded() { -// Element expanded = new Element("expandedServices"); -// for (Enumeration e = htExpanded.keys(); e.hasMoreElements(); ) { -// Integer serviceId = (Integer)e.nextElement(); -// boolean ex = ((Boolean)htExpanded.get(serviceId)).booleanValue(); -// expanded.addContent(new Element("service") -// .setAttribute("id", serviceId.toString()) -// .setAttribute("expanded", ex ? "true" : "false")); -// } Element expanded = new Element("expandedServices"); for(Integer id: _layers.keySet()) @@ -496,19 +469,9 @@ if (reaspectWms) bBox = reaspect(bBox, width, height); // Reaspect the bounding box if no ArcIMS service did it -// for (int i = 0; i < vRank.size(); i++) -// { -// MapService ms = (MapService)htServices.get(vRank.get(i)); -// if (htShow.get(vRank.get(i)).equals(new Boolean(true))) -// { -// try { vImageUrls.add(ms.getImageUrl(bBox, width, height)); } -// catch (Exception e) { e.printStackTrace(); /* DEBUG */ } -// } -// else vImageUrls.add(null); -// } - for (int rank: vRank) + for (int id: vRank) // takes ids sorted by their ranks { - Layer layer = _layers.get(rank); + Layer layer = _layers.get(id); MapService ms = layer.getService(); if (layer.isVisible()) { @@ -554,10 +517,6 @@ c.setCache(cache); // DEBUG c.checkIfModified(false); //DEBUG -// for (int i = 0; i < vImageUrls.size(); i++) { -// if ((String)vImageUrls.get(i) != null) { // null if some error encountered (never with WMS servers) -// c.register((String)vImageUrls.get(i)); -// } for (String url: vImageUrls) { if (url != null) { // null if some error encountered (never with WMS servers) @@ -586,7 +545,6 @@ if (contentType.startsWith("image")) { files.add(path); -// vTransparency.add(htTransparency.get(vRank.get(i))); vTransparency.add(_layers.get(vRank.get(i)).getTransparency()); //System.out.println("file: " + path + "; transparency: " + htTransparency.get(vRank.get(i))); // DEBUG } @@ -747,25 +705,6 @@ System.out.println("REASPECTING - WE fit, NS = " + ns); } } - -// if ((Math.abs(east - west)) > 360) -// { -// east = 180; -// west = -180; -// float d = (float)h / w * 180; -// north = d; -// south = -d; -// } -// -// if ((Math.abs(north - south)) > 180) { -// north = 90; -// south = -90; -// float d = (float)w / h * 90; -// east = d; -// west = -d; -// } -// - // System.out.println("north = " + north + "; south = " + south + "; east = " + east + "; west = " + west); return new BoundingBox(north, south, east, west); @@ -856,29 +795,4 @@ } } -class Layer -{ - private final MapService _service; - private float _transparency = 1.0F; - private boolean _expanded = true; - private boolean _visible = true; - public Layer(MapService service) - { - _service = service; - } - -// public void setService(MapService service){_service = service;} - public MapService getService(){return _service;} - - public void setTransparency(float transparency){_transparency = transparency;} - public float getTransparency(){return _transparency;} - public int getIntTransparency(){return (int)(_transparency * 100);} - - public void setExpanded(boolean isExpanded){_expanded = isExpanded;} - public boolean isExpanded(){return _expanded;} - - public void setVisible(boolean isVisibile){_visible = isVisibile;} - public boolean isVisible(){return _visible;} -} - Modified: trunk/src/org/wfp/vam/intermap/services/map/MapUtil.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/map/MapUtil.java 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/src/org/wfp/vam/intermap/services/map/MapUtil.java 2007-09-15 15:25:17 UTC (rev 825) @@ -1,25 +1,25 @@ /** - * Common.java - * - * @author Created by Omnicore CodeGuide */ package org.wfp.vam.intermap.services.map; -import java.util.*; - -import org.jdom.*; - -import jeeves.server.context.*; - -import org.wfp.vam.intermap.kernel.map.mapServices.*; -import org.wfp.vam.intermap.kernel.map.mapServices.arcims.*; -import org.wfp.vam.intermap.kernel.map.mapServices.wms.*; - -import org.wfp.vam.intermap.Constants; -import org.wfp.vam.intermap.kernel.map.*; import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; import jeeves.server.UserSession; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; +import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.DefaultMapServers; +import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; +import org.wfp.vam.intermap.kernel.map.mapServices.MapService; +import org.wfp.vam.intermap.kernel.map.mapServices.arcims.ArcIMSService; +import org.wfp.vam.intermap.kernel.map.mapServices.wms.WmsGetCapClient; +import org.wfp.vam.intermap.kernel.map.mapServices.wms.WmsService; public class MapUtil { @@ -132,8 +132,6 @@ public static int addService(int serverType, String serverUrl, String serviceName, String vsp, MapMerger mm) throws Exception { // Do not add the service if it is already there -// for (Enumeration e = mm.getServices(); e.hasMoreElements(); ) { -// MapService ms = (MapService)e.nextElement(); for(MapService service: mm.getServices()) { String url = service.getServerURL(); @@ -143,20 +141,21 @@ } int ret; - + switch (serverType) { case ArcIMSService.TYPE : ret = mm.addService(new ArcIMSService(serverUrl, serviceName)); break; - + case WmsService.TYPE : Element capabilities = WmsGetCapClient.getCapabilities(serverUrl); +// Element capabilities = CapabilitiesStore.getCapabilities(serverUrl); NEW VERSION: WORK IN PROGRESS WmsService s = new WmsService(serverUrl, serviceName, capabilities); ret = mm.addService(s); setVendorSpecificParams(s, vsp); break; - + default: throw new IllegalArgumentException("Unknown serverType " + serverType + " for service " + serviceName + " @ " + serverUrl); @@ -189,7 +188,7 @@ // System.out.println("hmParams: " + hmParams); service.setVendorSpecificParams(hmParams); //TEST } - + public static void setDefaultContext(MapMerger mm) throws Exception { Element mapContext = DefaultMapServers.getDefaultContext(); @@ -213,15 +212,10 @@ MapUtil.setDefBoundingBox(mm); } - + public static void setDefBoundingBox(MapMerger mm) throws Exception { -// Vector v = new Vector(); -// for (Enumeration e = mm.getServices(); e.hasMoreElements(); ) -// v.add( ((MapService)e.nextElement()).getDefBoundingBox() ); -// mm.setBoundingBox(BoundingBox.union(v)); - List<BoundingBox> lbb = new ArrayList<BoundingBox>(); for(MapService service: mm.getServices()) lbb.add( service.getDefBoundingBox() ); @@ -246,6 +240,9 @@ } } + /** + * @deprecated ETj: image dimensions are no longer handled server side + */ public static int getImageWidth(ServiceContext srvContext) { String size = (String)srvContext.getUserSession().getProperty(Constants.SESSION_SIZE); int width; @@ -255,6 +252,9 @@ return width; } + /** + * @deprecated ETj: image dimensions are no longer handled server side + */ public static int getImageHeight(ServiceContext srvContext) { String size = (String)srvContext.getUserSession().getProperty(Constants.SESSION_SIZE); int height; @@ -279,15 +279,10 @@ MapUtil.url = url; } - public static String getTempUrl() { return MapUtil.url; } - protected static Element getExtents(WmsService service) throws Exception { - return service.getExtents(); - } - protected static void moveTo(BoundingBox bb, int x, int y, int width, int height) throws Exception { float mapX = bb.getWest() + (bb.getEast() - bb.getWest()) * x / width; @@ -328,6 +323,22 @@ return new BoundingBox(north, south, east, west); } + public static BoundingBox setScale(BoundingBox bb, int imageWidth, int imageHeight, long scale, float dpi) + throws Exception + { + float cx = (bb.getEast()+bb.getWest())/2; + float cy = (bb.getNorth()+bb.getSouth())/2; + + // Set the scale + double degScale = scale/423307109.727 * 96f/dpi; + float dx = (float)(imageWidth * degScale); + float dy = (float)(imageHeight * degScale); + + return new BoundingBox( cy+dy/2, cy-dy/2, + cx+dx/2, cx-dx/2); + } + + public static void setDefaultImageSize(String s) { defaultImageSize = s; } @@ -338,3 +349,4 @@ } + Added: trunk/src/org/wfp/vam/intermap/services/map/SetScale.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/map/SetScale.java (rev 0) +++ trunk/src/org/wfp/vam/intermap/services/map/SetScale.java 2007-09-15 15:25:17 UTC (rev 825) @@ -0,0 +1,57 @@ +package org.wfp.vam.intermap.services.map; + + +import jeeves.interfaces.Service; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import org.jdom.Element; +import org.wfp.vam.intermap.Constants; +import org.wfp.vam.intermap.kernel.map.MapMerger; +import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; +import org.wfp.vam.intermap.util.Util; + +/** + * + */ + +public class SetScale implements Service +{ + public void init(String appPath, ServiceConfig config) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Service + //--- + //-------------------------------------------------------------------------- + + public Element exec(Element params, ServiceContext context) throws Exception + { + int width = Integer.parseInt(params.getChildText("width")); + int height = Integer.parseInt(params.getChildText("height")); + + int scale = Integer.parseInt(params.getChildText("scale")); + + MapMerger mm = MapUtil.getMapMerger(context); + + BoundingBox bb = Util.parseBoundingBox(params); // search bb in params + if( bb == null) + bb = mm.getBoundingBox(); + + BoundingBox scaledBB = MapUtil.setScale(bb, width, height, scale, mm.getDpi()); + mm.setBoundingBox(scaledBB); + + // Merge the images now + String imagename = mm.merge(width, height); + String url = MapUtil.getTempUrl() + "/" + imagename; + + return new Element("response") + .addContent(new Element("imgUrl").setText(url)) + .addContent(new Element("scale").setText(mm.getDistScale())) + .addContent(mm.getBoundingBox().toElement()) + .addContent(new Element("width").setText(""+width)) + .addContent(new Element("height").setText(""+height)); + } +} + +//============================================================================= + Modified: trunk/web/intermap/WEB-INF/config.xml =================================================================== --- trunk/web/intermap/WEB-INF/config.xml 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/web/intermap/WEB-INF/config.xml 2007-09-15 15:25:17 UTC (rev 825) @@ -299,7 +299,13 @@ <service name="map.move"> <class name=".services.map.Move" /> </service> + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <service name="map.setScale"> + <class name=".services.map.SetScale" /> + </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="map.update"> @@ -485,7 +491,12 @@ <output forward="map.getMain"/> </service> - + +<!-- <service name="wmc.getContext"> + <class name=".services.wmc.GetWmcContext"/> + <!-- need dome trasnformation here --> + </service> +--> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="wmc.setContextFromURL"> @@ -527,7 +538,14 @@ </class> </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> +<!-- <service name="wmc.mailform"> + <class name=".services.wmc.GetWmcContext"/> + <output sheet="im_wmc_form.xsl" contentType="text/html; charset=UTF-8" /> + </service> +--> + </services> Modified: trunk/web/intermap/scripts/im_ajax.js =================================================================== --- trunk/web/intermap/scripts/im_ajax.js 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/web/intermap/scripts/im_ajax.js 2007-09-15 15:25:17 UTC (rev 825) @@ -195,7 +195,26 @@ ); } +function imc_bm_setScale(w, h, bbox, scale ) +{ + var url = '/intermap/srv/en/map.setScale'; + var pars = "width=" + w + "&height="+h + + "&"+bbox+ + "&scale=" + scale; + setStatus('busy'); + + var myAjax = new Ajax.Request ( + url, + { + method: 'get', + parameters: pars, + onComplete: updateMapImage, + onFailure: reportError + } + ); +} + /***************************************************************************** * * * Area of interest * @@ -376,39 +395,6 @@ - -// improve me: this setting should be implemented client-side -// this setting refers to big map only, while ajax calls should be independent from which map are they called on -/*function imc_toggleImageSize() -{ - deleteAoi(); - unsetAoi(); - $('im_geonetRecords').className = 'hidden'; - - setStatus('busy'); - var url = '/intermap/srv/en/map.toggleImageSize'; - var myAjax = new Ajax.Request ( - url, - { - method: 'get', - onComplete: im_imageSizeToggled, - onFailure: reportError - } - ); -} -*/ -// improve me: this setting should be implemented client-side -// this setting refers to big map only, while ajax calls should be independent from which map are they called on -/*function im_imageSizeToggled(req) -{ - var w = req.responseXML.getElementsByTagName('width')[0].firstChild.nodeValue; - var h = req.responseXML.getElementsByTagName('height')[0].firstChild.nodeValue; - - im_bm_setSize(w,h); - - imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox()); -} -*/ function imc_addService(surl, service, type, callback) { var url = '/intermap/srv/en/map.addServices.embedded'; Modified: trunk/web/intermap/scripts/im_bigmap.js =================================================================== --- trunk/web/intermap/scripts/im_bigmap.js 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/web/intermap/scripts/im_bigmap.js 2007-09-15 15:25:17 UTC (rev 825) @@ -64,15 +64,6 @@ im_bm_west = new Number(w); } -// Set width, height and bounding box -function im_bm_setMapBB(n, e, s, w) -{ - im_bm_north=new Number(n); - im_bm_east = new Number(e); - im_bm_south = new Number(s); - im_bm_west = new Number(w); -} - function im_bm_setSize(w, h) { im_bm_width=new Number(w); @@ -977,6 +968,21 @@ /***************************************************************************** * + * Scale + * + *****************************************************************************/ + + +function im_bm_setScale() +{ + imc_bm_setScale(im_bm_width, im_bm_height, + im_bm_getURLbbox(), + $('im_setscale').value); +} + + +/***************************************************************************** + * * Generic utility functions * *****************************************************************************/ @@ -1150,6 +1156,8 @@ deleteChildNodes($('im_scale')); $('im_scale').appendChild( document.createTextNode('1:' + scale)); + $('im_currentscale').innerHTML= '1:' + scale; + $('im_setscale').selectedIndex = 0; // Event.observe(vMapImg, 'load', function(e) { setStatus('idle') }); // better behaviour but needs debugging on explorer (newer version of prototype?) setStatus('idle'); Modified: trunk/web/intermap/xml/user-profiles.xml =================================================================== --- trunk/web/intermap/xml/user-profiles.xml 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/web/intermap/xml/user-profiles.xml 2007-09-15 15:25:17 UTC (rev 825) @@ -29,9 +29,9 @@ <allow service="map.getLayers.embedded"/> <allow service="map.action"/> <allow service="map.move"/> + <allow service="map.setScale"/> <allow service="map.fullExtent"/> <allow service="map.zoomToService"/> - <allow service="map.toggleImageSize"/> <allow service="map.reset"/> <allow service="map.identify"/> <allow service="map.service.moveUp"/> @@ -49,8 +49,12 @@ <allow service="map.getPrintImage"/> <allow service="map.setContext"/> <allow service="map.getFeatures"/> + <allow service="wmc.setContext"/> +<!-- <allow service="wmc.getContext"/>--> <allow service="wmc.setContextFromURL"/> +<!-- <allow service="wmc.mailform"/>--> + <allow service="map.layers.deleteLayer"/> <allow service="map.layers.getOrder"/> <allow service="map.layers.setOrder"/> Modified: trunk/web/intermap/xsl/index-embedded.xsl =================================================================== --- trunk/web/intermap/xsl/index-embedded.xsl 2007-09-14 18:27:13 UTC (rev 824) +++ trunk/web/intermap/xsl/index-embedded.xsl 2007-09-15 15:25:17 UTC (rev 825) @@ -23,7 +23,7 @@ <td class="im_tool" id="im_tool_fullextent" onClick="javascript:im_bm_fullExtent()"><img src="{/root/gui/url}/images/zoomfull.png" title="Zoom to full map extent"/></td> <td class="im_tool" id="im_tool_zoomin" onClick="javascript:setTool('zoomin');" ><img src="{/root/gui/url}/images/zoomin.png" title="Zoom in"/></td> <td class="im_tool" id="im_tool_zoomout" onClick="javascript:setTool('zoomout');"><img src="{/root/gui/url}/images/zoomout.png" title="Zoom out"/></td> - <td class="im_tool" id="im_tool_pan" onClick="javascript:setTool('pan');"><img src="{/root/gui/url}/images/pan.png" title="Pan"/></td> + <td class="im_tool" id="im_tool_pan" onClick="javascript:setTool('pan');"><img src="{/root/gui/url}/images/pan.png" title="Pan"/></td> <!-- <td class="im_tool" id="im_tool_zoomsel" onClick="javascript:imc_zoomToLayer(activeLayerId)"><img src="{/root/gui/url}/images/zoomsel.png" title="Zoom to selected layer extent"/></td> --> <!-- <td class="im_tool" id="im_tool_aoi" onClick="javascript:setTool('aoi')"><img src="{/root/gui/url}/images/im_aoi16x16.png" title="Select an Area Of Interest"/></td> --> <!-- <td class="im_tool" id="im_tool_identify" onClick="javascript:setTool('identify');">Identify</td> --> @@ -97,6 +97,24 @@ <!-- <td style="padding:2px" onClick="im_sendMail();" ><a><img src="{/root/gui/url}/images/im_mail.png" title="Send this map via e-mail"/></a></td> --> <td style="padding:2px" onClick="im_openPDFform();" ><a><img src="{/root/gui/url}/images/acroread.png" title="Export this map as a PDF"/></a></td> <!-- <td style="padding:2px" onClick="im_openPictureForm();" ><a><img src="{/root/gui/url}/images/im_exportPic.png" title="Export this map as an image"/></a></td> --> + <td style="padding:2px" onClick="im_openWMCform();" ><a><img src="{/root/gui/url}/images/im_exportPic.png" title="View context"/></a></td> + <td width="100%" style="border-top:0px;"/> <!-- spacer --> + <td class="im_tool" id="im_tool_scale"> + <select name="im_setscale" id="im_setscale" onchange="javascript:im_bm_setScale();"> + <option id="im_currentscale" value="">1:?</option> + <option value="50000000">1:50.000.000</option> + <option value="10000000">1:10.000.000</option> + <option value="5000000">1:5.000.000</option> + <option value="1000000">1:1.000.000</option> + <option value="500000">1:500.000</option> + <option value="100000">1:100.000</option> + <option value="50000">1:50.000</option> + <option value="10000">1:10.000</option> + <option value="5000">1:5.000</option> + <option value="1000">1:1.000</option> + </select> + </td> + </tr> </table> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tic...@us...> - 2007-09-16 20:52:25
|
Revision: 830 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=830&view=rev Author: ticheler Date: 2007-09-16 13:52:25 -0700 (Sun, 16 Sep 2007) Log Message: ----------- Revert to Jetty version 5 due to installer and GAST incompatibility Fixed GeoServer loading on Jetty 5 (included required JARs for GeoServer/JSP pages) Modified Paths: -------------- trunk/bin/jetty.xml Removed Paths: ------------- trunk/jetty/etc/realm.properties trunk/jetty/etc/webdefault.xml trunk/jetty/ext/jetty-6.0.1.jar trunk/jetty/ext/jetty-util-6.0.1.jar trunk/jetty/ext/servlet-api-2.5-6.0.1.jar trunk/jetty/ext/xercesImpl-2.6.2.jar trunk/jetty/ext/xmlParserAPIs-2.6.2.jar trunk/jetty/lib/ant-1.6.4.jar trunk/jetty/lib/commons-el-1.0.jar trunk/jetty/lib/jasper-compiler-5.5.15.jar trunk/jetty/lib/jasper-compiler-jdt-5.5.15.jar trunk/jetty/lib/jasper-runtime-5.5.15.jar trunk/jetty/lib/jcl104-over-slf4j-1.0.1.jar trunk/jetty/lib/jetty-6.0.1.jar trunk/jetty/lib/jetty-util-6.0.1.jar trunk/jetty/lib/jsp-api-2.0.jar trunk/jetty/lib/servlet-api-2.5-6.0.1.jar trunk/jetty/lib/slf4j-simple-1.0.1.jar trunk/jetty/lib/xercesImpl-2.6.2.jar trunk/jetty/lib/xmlParserAPIs-2.6.2.jar Modified: trunk/bin/jetty.xml =================================================================== --- trunk/bin/jetty.xml 2007-09-15 19:14:53 UTC (rev 829) +++ trunk/bin/jetty.xml 2007-09-16 20:52:25 UTC (rev 830) @@ -1,174 +1,60 @@ -<?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> - -<!-- =============================================================== --> -<!-- Configure the Jetty Server --> -<!-- =============================================================== --> -<Configure id="Server" class="org.mortbay.jetty.Server"> - - <!-- =========================================================== --> - <!-- Server Thread Pool --> - <!-- =========================================================== --> - <Set name="ThreadPool"> - <New class="org.mortbay.thread.BoundedThreadPool"> - <Set name="minThreads">10</Set> - <Set name="lowThreads">50</Set> - <Set name="maxThreads">250</Set> - </New> - </Set> - - <!-- =========================================================== --> - <!-- Set connectors --> - <!-- =========================================================== --> - <!-- One of each type! --> - <!-- =========================================================== --> - - <!-- Use this connector for many frequently idle connections - and for threadless continuations. - --> - <Call name="addConnector"> - <Arg> - <New class="org.mortbay.jetty.nio.SelectChannelConnector"> - <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set> - <Set name="maxIdleTime">30000</Set> - <Set name="Acceptors">2</Set> - <Set name="confidentialPort">8443</Set> - </New> - </Arg> - </Call> - - - <!-- Use this connector if NIO is not available. - <Call name="addConnector"> - <Arg> - <New class="org.mortbay.jetty.bio.SocketConnector"> - <Set name="port">8081</Set> - <Set name="maxIdleTime">50000</Set> - <Set name="lowResourceMaxIdleTime">1500</Set> - </New> - </Arg> - </Call> - --> - - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- To add a HTTPS SSL listener --> - <!-- see jetty-ssl.xml to add an ssl connector. use --> - <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - - - <!-- =========================================================== --> - <!-- Set handler Collection Structure --> - <!-- =========================================================== --> - <Set name="handler"> - <New id="handlers" class="org.mortbay.jetty.handler.HandlerCollection"> - <Set name="handlers"> - <Array type="org.mortbay.jetty.Handler"> - <Item> - <New id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/> - </Item> - <Item> - <New id="defaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/> - </Item> - <Item> - <New id="requestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/> - </Item> - </Array> - </Set> - </New> - </Set> - - - <!-- ======================================================= --> - <!-- Configure a WebApp --> - <!-- ======================================================= --> - <!-- - <New id="TestContext" class="org.mortbay.jetty.webapp.WebAppContext"> - <Arg><Ref id="contexts"/></Arg> - <Arg><SystemProperty name="jetty.home" default="."/>/webapps/test</Arg> - <Arg>/</Arg> - <Set name="classLoader"> - <New class="org.mortbay.jetty.webapp.TransformingWebAppClassLoader"> - <Arg><Ref id="TestContext"/></Arg> - </New> - </Set> - <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set> - <Set name="virtualHosts"> - <Array type="java.lang.String"> - <Item>localhost</Item> - </Array> - </Set> - - <Get name="SessionHandler"> - <Set name="SessionManager"> - <New class="org.mortbay.jetty.servlet.HashSessionManager"> - <Set name="maxInactiveInterval">600</Set> - </New> - </Set> - </Get> - </New> - --> - - <!-- ======================================================= --> - <!-- Configure a Context --> - <!-- ======================================================= --> - <New class="org.mortbay.jetty.servlet.Context"> - <Arg><Ref id="contexts"/></Arg> - <Arg>/javadoc</Arg> - <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set> - <Call name="addServlet"> - <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg> - <Arg>/</Arg> - </Call> - </New> - - <!-- =========================================================== --> - <!-- Discover contexts from webapps directory --> - <!-- =========================================================== --> - <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications"> - <Arg><Ref id="contexts"/></Arg> - <Arg><SystemProperty name="jetty.home" default="."/>/../web</Arg> - <Arg><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Arg> - <Arg type="boolean">True</Arg> <!-- extract --> - <Arg type="boolean">True</Arg> <!-- parent priority class loading --> - </Call> - - <!-- =========================================================== --> - <!-- Configure Realms --> - <!-- =========================================================== --> - <Set name="UserRealms"> - <Array type="org.mortbay.jetty.security.UserRealm"> - <Item> - <New class="org.mortbay.jetty.security.HashUserRealm"> - <Set name="name">Test Realm</Set> - <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set> - </New> - </Item> - </Array> - </Set> - - - <!-- =========================================================== --> - <!-- Configure Request Log --> - <!-- =========================================================== --> - <Ref id="requestLog"> - <Set name="requestLog"> - <New id="requestLogImpl" class="org.mortbay.jetty.NCSARequestLog"> - <Arg><SystemProperty name="jetty.logs" default="log"/>/yyyy_mm_dd.request.log</Arg> - <Set name="retainDays">90</Set> - <Set name="append">true</Set> - <Set name="extended">false</Set> - <Set name="LogTimeZone">GMT</Set> - </New> - </Set> - </Ref> - - <!-- =========================================================== --> - <!-- extra options --> - <!-- =========================================================== --> - <Set name="stopAtShutdown">true</Set> - <!-- ensure/prevent Server: header being sent to browsers --> - <Set name="sendServerVersion">true</Set> - -</Configure> +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "jetty-configure_1_3.dtd"> +<Configure class="org.mortbay.jetty.Server"> + + <Call name="addListener"> + <Arg> + <New class="org.mortbay.http.SocketListener"> + <Set name="port">8080</Set> + <Set name="MinThreads">10</Set> + <Set name="MaxThreads">200</Set> + <Set name="MaxIdleTimeMs">30000</Set> + <Set name="lowResources">50</Set> + <Set name="LowResourcePersistTimeMs">2000</Set> + </New> + </Arg> + </Call> + + <!-- ============================================================ --> + + <Set name="WebApplicationConfigurationClassNames"> + <Array type="java.lang.String"> + <Item>org.mortbay.jetty.servlet.XMLConfiguration</Item> + <Item>org.mortbay.jetty.servlet.JettyWebConfiguration</Item> + </Array> + </Set> + + <!-- ============================================================ --> + + <Call name="addWebApplication"> + <Arg>/geonetwork</Arg> + <Arg>../web/geonetwork</Arg> + </Call> + + <!-- =============================================================== --> + + <Call name="addWebApplication"> + <Arg>/intermap</Arg> + <Arg>../web/intermap</Arg> + </Call> + + <!-- =============================================================== --> + + <Call name="addWebApplication"> + <Arg>/geoserver</Arg> + <Arg>../web/geoserver</Arg> + </Call> + + <!-- =============================================================== --> + + <Set name="RequestLog"> + <New class="org.mortbay.http.NCSARequestLog"> + <Arg>../jetty/log/yyyy_mm_dd.request.log</Arg> + <Set name="retainDays">90</Set> + <Set name="append">false</Set> + <Set name="extended">false</Set> + <Set name="LogTimeZone">GMT</Set> + </New> + </Set> + +</Configure> Deleted: trunk/jetty/etc/realm.properties =================================================================== --- trunk/jetty/etc/realm.properties 2007-09-15 19:14:53 UTC (rev 829) +++ trunk/jetty/etc/realm.properties 2007-09-16 20:52:25 UTC (rev 830) @@ -1,21 +0,0 @@ -# -# This file defines users passwords and roles for a HashUserRealm -# -# The format is -# <username>: <password>[,<rolename> ...] -# -# Passwords may be clear text, obfuscated or checksummed. The class -# org.mortbay.util.Password should be used to generate obfuscated -# passwords or password checksums -# -# If DIGEST Authentication is used, the password must be in a recoverable -# format, either plain text or OBF:. -# -jetty: MD5:164c88b302622e17050af52c89945d44,user -admin: CRYPT:ad1ks..kc.1Ug,server-administrator,content-administrator,admin -other: OBF:1xmk1w261u9r1w1c1xmq -plain: plain -user: password - -# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password -digest: MD5:6e120743ad67abfbc385bc2bb754e297 Deleted: trunk/jetty/etc/webdefault.xml =================================================================== --- trunk/jetty/etc/webdefault.xml 2007-09-15 19:14:53 UTC (rev 829) +++ trunk/jetty/etc/webdefault.xml 2007-09-16 20:52:25 UTC (rev 830) @@ -1,347 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<!-- ===================================================================== --> -<!-- This file contains the default descriptor for web applications. --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- The intent of this descriptor is to include jetty specific or common --> -<!-- configuration for all webapps. If a context has a webdefault.xml --> -<!-- descriptor, it is applied before the contexts own web.xml file --> -<!-- --> -<!-- A context may be assigned a default descriptor by: --> -<!-- + Calling WebApplicationContext.setDefaultsDescriptor --> -<!-- + Passed an arg to addWebApplications --> -<!-- --> -<!-- This file is used both as the resource within the jetty.jar (which is --> -<!-- used as the default if no explicit defaults descriptor is set) and it --> -<!-- is copied to the etc directory of the Jetty distro and explicitly --> -<!-- by the jetty.xml file. --> -<!-- --> -<!-- ===================================================================== --> -<web-app - xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" - version="2.5"> - - <description> - Default web.xml file. - This file is applied to a Web application before it's own WEB_INF/web.xml file - </description> - - - <!-- ==================================================================== --> - <!-- Context params to control Session Cookies --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- UNCOMMENT TO ACTIVATE - <context-param> - <param-name>org.mortbay.jetty.servlet.SessionDomain</param-name> - <param-value>127.0.0.1</param-value> - </context-param> - - <context-param> - <param-name>org.mortbay.jetty.servlet.SessionPath</param-name> - <param-value>/</param-value> - </context-param> - - <context-param> - <param-name>org.mortbay.jetty.servlet.MaxAge</param-name> - <param-value>-1</param-value> - </context-param> - --> - - - - <!-- ==================================================================== --> - <!-- The default servlet. --> - <!-- This servlet, normally mapped to /, provides the handling for static --> - <!-- content, OPTIONS and TRACE methods for the context. --> - <!-- The following initParameters are supported: --> - <!-- --> - <!-- acceptRanges If true, range requests and responses are --> - <!-- supported --> - <!-- --> - <!-- dirAllowed If true, directory listings are returned if no --> - <!-- welcome file is found. Else 403 Forbidden. --> - <!-- --> - <!-- redirectWelcome If true, redirect welcome file requests --> - <!-- else use request dispatcher forwards --> - <!-- --> - <!-- resoureBase Can be set to replace the context resource base --> - <!-- --> - <!-- relativeResourceBase --> - <!-- Set with a pathname relative to the base of the --> - <!-- servlet context root. Useful for only serving --> - <!-- static content from only specific subdirectories. --> - <!-- --> - <!-- useFileMappedBuffer --> - <!-- If set to true (the default), a memory mapped --> - <!-- file buffer will be used to serve static content --> - <!-- when using an NIO connector. Setting this value --> - <!-- to false means that a direct buffer will be used --> - <!-- instead. If you are having trouble with Windows --> - <!-- file locking, set this to false. --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <servlet> - <servlet-name>default</servlet-name> - <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class> - <init-param> - <param-name>acceptRanges</param-name> - <param-value>true</param-value> - </init-param> - <init-param> - <param-name>dirAllowed</param-name> - <param-value>true</param-value> - </init-param> - <init-param> - <param-name>redirectWelcome</param-name> - <param-value>false</param-value> - </init-param> - <init-param> - <param-name>maxCacheSize</param-name> - <param-value>2000000</param-value> - </init-param> - <init-param> - <param-name>maxCachedFileSize</param-name> - <param-value>254000</param-value> - </init-param> - <init-param> - <param-name>maxCachedFiles</param-name> - <param-value>1000</param-value> - </init-param> - <init-param> - <param-name>useFileMappedBuffer</param-name> - <param-value>true</param-value> - </init-param> - <load-on-startup>0</load-on-startup> - </servlet> - - <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> - - - <!-- ==================================================================== --> - <!-- JSP Servlet --> - <!-- This is the jasper JSP servlet from the jakarta project --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- The JSP page compiler and execution servlet, which is the mechanism --> - <!-- used by Tomcat to support JSP pages. Traditionally, this servlet --> - <!-- is mapped to URL patterh "*.jsp". This servlet supports the --> - <!-- following initialization parameters (default values are in square --> - <!-- brackets): --> - <!-- --> - <!-- checkInterval If development is false and reloading is true, --> - <!-- background compiles are enabled. checkInterval --> - <!-- is the time in seconds between checks to see --> - <!-- if a JSP page needs to be recompiled. [300] --> - <!-- --> - <!-- compiler Which compiler Ant should use to compile JSP --> - <!-- pages. See the Ant documenation for more --> - <!-- information. [javac] --> - <!-- --> - <!-- classdebuginfo Should the class file be compiled with --> - <!-- debugging information? [true] --> - <!-- --> - <!-- classpath What class path should I use while compiling --> - <!-- generated servlets? [Created dynamically --> - <!-- based on the current web application] --> - <!-- --> - <!-- development Is Jasper used in development mode (will check --> - <!-- for JSP modification on every access)? [true] --> - <!-- --> - <!-- enablePooling Determines whether tag handler pooling is --> - <!-- enabled [true] --> - <!-- --> - <!-- fork Tell Ant to fork compiles of JSP pages so that --> - <!-- a separate JVM is used for JSP page compiles --> - <!-- from the one Tomcat is running in. [true] --> - <!-- --> - <!-- ieClassId The class-id value to be sent to Internet --> - <!-- Explorer when using <jsp:plugin> tags. --> - <!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93] --> - <!-- --> - <!-- javaEncoding Java file encoding to use for generating java --> - <!-- source files. [UTF-8] --> - <!-- --> - <!-- keepgenerated Should we keep the generated Java source code --> - <!-- for each page instead of deleting it? [true] --> - <!-- --> - <!-- logVerbosityLevel The level of detailed messages to be produced --> - <!-- by this servlet. Increasing levels cause the --> - <!-- generation of more messages. Valid values are --> - <!-- FATAL, ERROR, WARNING, INFORMATION, and DEBUG. --> - <!-- [WARNING] --> - <!-- --> - <!-- mappedfile Should we generate static content with one --> - <!-- print statement per input line, to ease --> - <!-- debugging? [false] --> - <!-- --> - <!-- --> - <!-- reloading Should Jasper check for modified JSPs? [true] --> - <!-- --> - <!-- suppressSmap Should the generation of SMAP info for JSR45 --> - <!-- debugging be suppressed? [false] --> - <!-- --> - <!-- dumpSmap Should the SMAP info for JSR45 debugging be --> - <!-- dumped to a file? [false] --> - <!-- False if suppressSmap is true --> - <!-- --> - <!-- scratchdir What scratch directory should we use when --> - <!-- compiling JSP pages? [default work directory --> - <!-- for the current web application] --> - <!-- --> - <!-- tagpoolMaxSize The maximum tag handler pool size [5] --> - <!-- --> - <!-- xpoweredBy Determines whether X-Powered-By response --> - <!-- header is added by generated servlet [false] --> - <!-- --> - <!-- If you wish to use Jikes to compile JSP pages: --> - <!-- Set the init parameter "compiler" to "jikes". Define --> - <!-- the property "-Dbuild.compiler.emacs=true" when starting Jetty --> - <!-- to cause Jikes to emit error messages in a format compatible with --> - <!-- Jasper. --> - <!-- If you get an error reporting that jikes can't use UTF-8 encoding, --> - <!-- try setting the init parameter "javaEncoding" to "ISO-8859-1". --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <servlet id="jsp"> - <servlet-name>jsp</servlet-name> - <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> - <init-param> - <param-name>logVerbosityLevel</param-name> - <param-value>DEBUG</param-value> - </init-param> - <init-param> - <param-name>fork</param-name> - <param-value>false</param-value> - </init-param> - <init-param> - <param-name>xpoweredBy</param-name> - <param-value>false</param-value> - </init-param> - <load-on-startup>0</load-on-startup> - </servlet> - - <servlet-mapping> - <servlet-name>jsp</servlet-name> - <url-pattern>*.jsp</url-pattern> - <url-pattern>*.jspf</url-pattern> - <url-pattern>*.jspx</url-pattern> - <url-pattern>*.xsp</url-pattern> - <url-pattern>*.JSP</url-pattern> - <url-pattern>*.JSPF</url-pattern> - <url-pattern>*.JSPX</url-pattern> - <url-pattern>*.XSP</url-pattern> - </servlet-mapping> - <!-- ==================================================================== --> - <!-- Dynamic Servlet Invoker. --> - <!-- This servlet invokes anonymous servlets that have not been defined --> - <!-- in the web.xml or by other means. The first element of the pathInfo --> - <!-- of a request passed to the envoker is treated as a servlet name for --> - <!-- an existing servlet, or as a class name of a new servlet. --> - <!-- This servlet is normally mapped to /servlet/* --> - <!-- This servlet support the following initParams: --> - <!-- --> - <!-- nonContextServlets If false, the invoker can only load --> - <!-- servlets from the contexts classloader. --> - <!-- This is false by default and setting this --> - <!-- to true may have security implications. --> - <!-- --> - <!-- verbose If true, log dynamic loads --> - <!-- --> - <!-- * All other parameters are copied to the --> - <!-- each dynamic servlet as init parameters --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- Uncomment for dynamic invocation - <servlet> - <servlet-name>invoker</servlet-name> - <servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class> - <init-param> - <param-name>verbose</param-name> - <param-value>false</param-value> - </init-param> - <init-param> - <param-name>nonContextServlets</param-name> - <param-value>false</param-value> - </init-param> - <init-param> - <param-name>dynamicParam</param-name> - <param-value>anyValue</param-value> - </init-param> - <load-on-startup>0</load-on-startup> - </servlet> - - <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> - --> - - - - <!-- ==================================================================== --> - <session-config> - <session-timeout>30</session-timeout> - </session-config> - - <!-- ==================================================================== --> - <!-- Default MIME mappings --> - <!-- The default MIME mappings are provided by the mime.properties --> - <!-- resource in the org.mortbay.jetty.jar file. Additional or modified --> - <!-- mappings may be specified here --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- UNCOMMENT TO ACTIVATE - <mime-mapping> - <extension>mysuffix</extension> - <mime-type>mymime/type</mime-type> - </mime-mapping> - --> - - <!-- ==================================================================== --> - <welcome-file-list> - <welcome-file>index.html</welcome-file> - <welcome-file>index.htm</welcome-file> - <welcome-file>index.jsp</welcome-file> - </welcome-file-list> - - <!-- ==================================================================== --> - <locale-encoding-mapping-list> - <locale-encoding-mapping><locale>ar</locale><encoding>ISO-8859-6</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>be</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>bg</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>ca</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>cs</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>da</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>de</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>el</locale><encoding>ISO-8859-7</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>en</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>es</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>et</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>fi</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>fr</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>hr</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>hu</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>is</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>it</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>iw</locale><encoding>ISO-8859-8</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>ja</locale><encoding>Shift_JIS</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>ko</locale><encoding>EUC-KR</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>lt</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>lv</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>mk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>nl</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>no</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>pl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>pt</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>ro</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>ru</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sh</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sk</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sq</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sr</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>sv</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>tr</locale><encoding>ISO-8859-9</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>uk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>zh</locale><encoding>GB2312</encoding></locale-encoding-mapping> - <locale-encoding-mapping><locale>zh_TW</locale><encoding>Big5</encoding></locale-encoding-mapping> - </locale-encoding-mapping-list> - - - -</web-app> - Deleted: trunk/jetty/ext/jetty-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/ext/jetty-util-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/ext/servlet-api-2.5-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/ext/xercesImpl-2.6.2.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/ext/xmlParserAPIs-2.6.2.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/ant-1.6.4.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/commons-el-1.0.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jasper-compiler-5.5.15.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jasper-compiler-jdt-5.5.15.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jasper-runtime-5.5.15.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jcl104-over-slf4j-1.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jetty-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jetty-util-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/jsp-api-2.0.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/servlet-api-2.5-6.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/slf4j-simple-1.0.1.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/xercesImpl-2.6.2.jar =================================================================== (Binary files differ) Deleted: trunk/jetty/lib/xmlParserAPIs-2.6.2.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-09-18 13:04:19
|
Revision: 840 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=840&view=rev Author: e_tajariol Date: 2007-09-18 06:04:19 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Handling interactive maps for metadata with OnlineResources holding getCapabilities WMS servers. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/services/mapServers/GetServices.java trunk/web/geonetwork/geonetwork.css trunk/web/geonetwork/scripts/gn_search.js trunk/web/geonetwork/xsl/main-page.xsl trunk/web/geonetwork/xsl/metadata-iso19115.xsl trunk/web/geonetwork/xsl/metadata-iso19139.xsl trunk/web/geonetwork/xsl/search-results-xhtml.xsl trunk/web/intermap/intermap-embedded.css trunk/web/intermap/scripts/etj.js trunk/web/intermap/scripts/im_bigmap.js trunk/web/intermap/scripts/im_extras.js trunk/web/intermap/xsl/im_get-services-embedded.xsl Added Paths: ----------- trunk/web/geonetwork/scripts/gn_intermap.js Modified: trunk/src/org/wfp/vam/intermap/services/mapServers/GetServices.java =================================================================== --- trunk/src/org/wfp/vam/intermap/services/mapServers/GetServices.java 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/src/org/wfp/vam/intermap/services/mapServers/GetServices.java 2007-09-18 13:04:19 UTC (rev 840) @@ -55,7 +55,8 @@ Element response = new Element("response") .addContent(new Element("url").setText(serverUrl)) - .addContent(new Element("type").setText(serverType + "")); + .addContent(new Element("type").setText(serverType + "")) + .addContent(new Element("jscallback").setText(params.getChildText("jscallback"))); switch (serverType) { @@ -84,6 +85,7 @@ try { Element capabilities = WmsGetCapClient.getCapabilities(serverUrl); +// Element capabilities = CapabilitiesStore.getCapabilities(serverUrl); response.addContent(capabilities); } catch (Exception e) { @@ -102,3 +104,4 @@ //============================================================================= + Modified: trunk/web/geonetwork/geonetwork.css =================================================================== --- trunk/web/geonetwork/geonetwork.css 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/geonetwork.css 2007-09-18 13:04:19 UTC (rev 840) @@ -578,6 +578,7 @@ padding: 3px; border: 1px #266397 solid; background-color: #dce1ea; + position: relative; } div.metadata_current table, @@ -593,3 +594,6 @@ border-collapse: separate; } +.ilwhiteboard { + position:relative; +} Added: trunk/web/geonetwork/scripts/gn_intermap.js =================================================================== --- trunk/web/geonetwork/scripts/gn_intermap.js (rev 0) +++ trunk/web/geonetwork/scripts/gn_intermap.js 2007-09-18 13:04:19 UTC (rev 840) @@ -0,0 +1,236 @@ +/********************************************************** +*** +*** Here you can find functions related to gn adding layers to the +*** integrated map viewer. +*** +*********************************************************** +*** +*** In 19139/19115 md you can find online resources. +*** If such a resource refers to a WMS server, you can add its layers to the +*** current map. +*** +*** At the moment we can handle: +*** - WMS getMap service links (they point to exactly one layer in one server) +*** - WMS getCapabilitites (they point to a WMS server, and the user shell select which service to use) +*** +*** A metadata can have zero, one or more online resources. +*** - If a metadata holds only one onlineres, +*** - if it is a getMap, its related layer can be automatically added to the map Viewer. +*** - if it is a getCapab, a list of the layers offered by the server will be shown, and the user shall select the wanted ones. +*** If a metadata holds many onlineres, a list will be shown showing them all. +*** Selecting getMap resources, the user can add related layers to the map viewer, +*** selecting getCapab resources, a list of the layers offered by the server will be shown, and the user shall select the wanted ones. +*** 139/115 templates may call one two functions, +*** +*** +**********************************************************/ + +/* +## Hook from GN xsl for dynamic data +*/ +function runIM_addService(url, service, type) +{ + imc_addService(url, service, type, function(req) { + im_buildLayerList(req); + refreshNeeded(true); + //imc_mm_update(im_mm_width, im_mm_height); + }); +} + +/* +## Hook from GN xsl for dynamic data +## A server url has been specified. A list of selectable services will be displayed +*/ +function runIM_selectService(url, type, mdid) +{ + gn_showGetCapabilities(url, type, mdid); +} + +/******************************************************************** +* +* Show list of addable interactive maps +* +********************************************************************/ +/* +## This method is called by the "Interactive map [+]" button in a displayed metadata. +## It will display the metadata distribution info in a div . +*/ +function gn_showInterList(id) +{ + var pars = 'id=' + id + "&currTab=distribution"; + + // Change button appearance + $('gn_showinterlist_' + id) .hide(); + $('gn_loadinterlist_' + id) .show(); + + var myAjax = new Ajax.Request( + '/geonetwork/srv/en/metadata.show.embedded', + { + method: 'get', + parameters: pars, + onSuccess: function (req) { + // This is a normally invisible DIV below every MD + var parent = $('ilwhiteboard_' + id); + clearNode(parent); + + parent.show(); + + $('gn_loadinterlist_' + id) .hide(); + $('gn_hideinterlist_' + id) .show(); + + // create new element + var div = document.createElement('div'); + div.className = 'metadata_current'; + div.style.display = 'none'; + parent.appendChild(div); + + div.innerHTML = req.responseText; + + Effect.BlindDown(div); + + var tipman = new TooltipManager(); + ker.loadMan.wait(tipman); + }, + onFailure: gn_search_error// FIXME + }); +} + +function gn_hideInterList(id) +{ + var parent = $('ilwhiteboard_' + id); + var div = parent.firstChild; + Effect.BlindUp(div, { afterFinish: function (obj) { + clearNode(parent); + $('gn_showinterlist_' + id) .show(); + $('gn_hideinterlist_' + id) .hide(); + } + }); +} + +/******************************************************************** +* +* +* +********************************************************************/ + +/* +## Called +*/ +function gn_showGetCapabilities(url, type, id) +{ + // Change button appearance (they do not exist when we're showing getCapab for a 1-onlineresource-only md) + if($('gn_showinterlist_' + id)) $('gn_showinterlist_' + id) .show(); + if($('gn_loadinterlist_' + id)) $('gn_loadinterlist_' + id) .hide(); + if($('gn_hideinterlist_' + id)) $('gn_hideinterlist_' + id) .hide(); + + // This is a normally invisible DIV below every MD + var parent = $('ilwhiteboard_' + id); + clearNode(parent); + parent.show(); + + var div = document.createElement('div'); + div.className = 'metadata_current'; + parent.appendChild(div); + var t1 = document.createElement("p"); + t1.innerHTML = "Loading server layers, please wait..."; // fixme i18n + div.appendChild(t1); + + // Load and transform server's getCapabilities: + imc_loadURLServices(url, // WMS server + -2, // type = -2: free WMS server url + function(req) {gn_getCapabLoaded(req,id);}, // callback: function called when ajax request completes + "gn_layersRequested("+id+");" ); // jscallback: function called by the button in the HTML returned by the AJAX service (ugly hack) +} + +function gn_getCapabLoaded(req, mdid) +{ + var parent = $('ilwhiteboard_' + mdid); + clearNode(parent); + gn_addCloser(parent); + + var div = document.createElement('div'); + div.className = 'metadata_current'; + parent.appendChild(div); + + div.innerHTML = req.responseText; +} + +/* +## Called by the ok button generated by service mapServers.getServices.embedded +*/ +function gn_layersRequested(mdid) +{ + var im = $('ilwhiteboard_' + mdid); + //var im = $('im_serverList'); + + // next two elements are created by the mapServers.getServices.embedded service + var url = $('im_addlayer_serverurl').value; + var type = $('im_addlayer_type').value; + + var services = new Array(); + var lilist = im.getElementsByTagName("input"); + + $A(lilist).each( + function (input) + { + var value = input.value; + var checked = input.checked; + + if(checked) + { + services.push(value); + } + } + ); + + // setStatus('busy'); <-- we may need it + + imc_addServices(url, services, type, function(req) {gn_layersAdded(req,mdid);}); +} + +function gn_layersAdded(req, mdid) +{ + var parent = $('ilwhiteboard_' + mdid); + clearNode(parent); + gn_addCloser(parent); + + var div = document.createElement('div'); + div.className = 'metadata_current'; + parent.appendChild(div); + var t1 = document.createElement("p"); + t1.innerHTML = "Selected layers have been added"; // fixme i18n + div.appendChild(t1); + + + im_buildLayerList(req); // rebuild layers' list + + // refreshes should be chained + refreshNeeded(true); // refresh big map + im_mm_refreshNeeded(); // refresh minimap +} + + +function gn_addCloser(domnode, callback) +{ + var closer = Builder.node('div', {class: "im_wbcloser"}); + var img = Builder.node('img', + { + title: "Close", // FIXME i18N + src: "/intermap/images/close.png" + }); + closer.appendChild(img); + + domnode.appendChild(closer); + Event.observe(closer, 'click', + function() + { + clearNode(domnode); + if(callback) + callback(); + // TODO we should also remove the current observer + }); + +} + + +/* EOF ******************************************************* EOF */ Modified: trunk/web/geonetwork/scripts/gn_search.js =================================================================== --- trunk/web/geonetwork/scripts/gn_search.js 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/scripts/gn_search.js 2007-09-18 13:04:19 UTC (rev 840) @@ -340,68 +340,7 @@ alert("ERROR)"); } -/******************************************************************** -* -* Show list of addable interactive maps -* -********************************************************************/ -function gn_showInterList(id) -{ - var pars = 'id=' + id + "&currTab=distribution"; - - $('gn_showinterlist_' + id) .hide(); - $('gn_loadinterlist_' + id) .show(); - - var myAjax = new Ajax.Request( - '/geonetwork/srv/en/metadata.show.embedded', - { - method: 'get', - parameters: pars, - onSuccess: function (req) { - // remove previous open md - //var prev = document.getElementById('metadata_current'); - //if(prev) - // prev.parentNode.removeChild($('metadata_current')); - - var parent = $('ilwhiteboard_' + id); - clearNode(parent); - - parent.show(); - - $('gn_loadinterlist_' + id) .hide(); - $('gn_hideinterlist_' + id) .show(); - - // create new element - var div = document.createElement('div'); - div.className = 'metadata_current'; - div.style.display = 'none'; - parent.appendChild(div); - - div.innerHTML = req.responseText; - - Effect.BlindDown(div); - - var tipman = new TooltipManager(); - ker.loadMan.wait(tipman); - }, - onFailure: gn_search_error// FIXME - }); -} - -function gn_hideInterList(id) -{ - var parent = $('ilwhiteboard_' + id); - var div = parent.firstChild; - Effect.BlindUp(div, { afterFinish: function (obj) { - clearNode(parent); - $('gn_showinterlist_' + id) .show(); - $('gn_hideinterlist_' + id) .hide(); - } - }); -} - - /********************************************************** *** *** STUFF FOR SIMPLE SEARCH Modified: trunk/web/geonetwork/xsl/main-page.xsl =================================================================== --- trunk/web/geonetwork/xsl/main-page.xsl 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/xsl/main-page.xsl 2007-09-18 13:04:19 UTC (rev 840) @@ -25,6 +25,7 @@ <script type="text/javascript" src="{/root/gui/url}/scripts/gn_search.js?"/> + <script type="text/javascript" src="{/root/gui/url}/scripts/gn_intermap.js?"/> <script type="text/javascript" src="/intermap/scripts/etj.js?"/> <script type="text/javascript" src="/intermap/scripts/im_extras.js?"/> Modified: trunk/web/geonetwork/xsl/metadata-iso19115.xsl =================================================================== --- trunk/web/geonetwork/xsl/metadata-iso19115.xsl 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/xsl/metadata-iso19115.xsl 2007-09-18 13:04:19 UTC (rev 840) @@ -999,7 +999,7 @@ <!-- ETj <a href="javascript:popInterMap('{/root/gui/url}/intermap/srv/{/root/gui/language}/map.addServicesExt?url={linkage}&type=2')" title="{/root/strings/interactiveMap}"> --> - <a href="javascript:runIM_selectService('{linkage}',2)" title="{/root/strings/interactiveMap}"> + <a href="javascript:runIM_selectService('{linkage}',2,{//geonet:info/id})" title="{/root/strings/interactiveMap}"> <xsl:choose> <xsl:when test="string(orDesc)!=''"> @@ -1741,7 +1741,7 @@ <xsl:when test="starts-with(./protocol,'OGC:WMS-') and contains(./protocol,'-get-capabilities') and ./orName"> <link type="wms"> <!-- ETj <xsl:value-of select="concat('javascript:popInterMap("',/root/gui/url,'/intermap/srv/',/root/gui/language,'/map.addServicesExt?url=',linkage,'&type=2")')"/> --> - <xsl:value-of select="concat('javascript:runIM_selectService("',linkage,'",2);')"/> + <xsl:value-of select="concat('javascript:runIM_selectService("',linkage,'",2,',$id,');')"/> </link> </xsl:when> <xsl:when test="linkage[text()]"> Modified: trunk/web/geonetwork/xsl/metadata-iso19139.xsl =================================================================== --- trunk/web/geonetwork/xsl/metadata-iso19139.xsl 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/xsl/metadata-iso19139.xsl 2007-09-18 13:04:19 UTC (rev 840) @@ -1544,7 +1544,7 @@ <!-- ETj <a href="javascript:popInterMap('{/root/gui/url}/intermap/srv/{/root/gui/language}/map.addServicesExt?url={gmd:linkage/gmd:URL}&type=2')" title="{/root/strings/interactiveMap}"> --> - <a href="javascript:runIM_selectService('{gmd:linkage/gmd:URL}',2)" title="{/root/strings/interactiveMap}"> + <a href="javascript:runIM_selectService('{gmd:linkage/gmd:URL}',2,{//geonet:info/id})" title="{/root/strings/interactiveMap}"> <xsl:choose> <xsl:when test="string(gmd:description/gco:CharacterString)!=''"> <xsl:value-of select="gmd:description/gco:CharacterString"/> @@ -1857,7 +1857,7 @@ <xsl:when test="starts-with($protocol,'OGC:WMS-') and contains($protocol,'-get-capabilities') and $name"> <link type="wms"> <!-- <xsl:value-of select="concat('javascript:popInterMap("',/root/gui/url,'/intermap/srv/',/root/gui/language,'/map.addServicesExt?url=',$linkage,'&type=2")')"/>--> - <xsl:value-of select="concat('javascript:runIM_selectService("' , $linkage , '", 2)' )"/> + <xsl:value-of select="concat('javascript:runIM_selectService("' , $linkage , '", 2,',$id,')' )"/> </link> </xsl:when> <xsl:when test="string($linkage)!=''"> Modified: trunk/web/geonetwork/xsl/search-results-xhtml.xsl =================================================================== --- trunk/web/geonetwork/xsl/search-results-xhtml.xsl 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/geonetwork/xsl/search-results-xhtml.xsl 2007-09-18 13:04:19 UTC (rev 840) @@ -362,7 +362,7 @@ </table> <!-- spare room for metdata display via AJAX --> - <div id="ilwhiteboard_{$metadata/geonet:info/id}" width="100%" style="display:none;">dummy string, or FF will nest next DIV into this one</div> + <div id="ilwhiteboard_{$metadata/geonet:info/id}" class="ilwhiteboard" width="100%" style="display:none;">dummy string, or FF will nest next DIV into this one</div> <div id="mdwhiteboard_{$metadata/geonet:info/id}" width="100%"></div> </xsl:template> Modified: trunk/web/intermap/intermap-embedded.css =================================================================== --- trunk/web/intermap/intermap-embedded.css 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/intermap/intermap-embedded.css 2007-09-18 13:04:19 UTC (rev 840) @@ -808,3 +808,13 @@ margin-left: 5px; } +.im_wbcloser { + position: absolute; + top:1px; + right:3px; + width: 16px; + height: 16px; + cursor: pointer; + + z-index: 20; +} Modified: trunk/web/intermap/scripts/etj.js =================================================================== --- trunk/web/intermap/scripts/etj.js 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/intermap/scripts/etj.js 2007-09-18 13:04:19 UTC (rev 840) @@ -142,26 +142,3 @@ *** LAYERS ********************************************************************/ -/* -## Hook from GN xsl for dynamic data -*/ -function runIM_addService(url, service, type) -{ - imc_addService(url, service, type, function(req) { - im_buildLayerList(req); - //imc_reloadLayers(); - imc_mm_update(im_mm_width, im_mm_height, null); - }); -} - - -/* -## Hook from GN xsl for dynamic data -## A server url has been specified. A list of selectable services will be diplayed -*/ -function runIM_selectService(url, type) -{ - alert("TODO (runIM_selectService)"); - // TODO -} - Modified: trunk/web/intermap/scripts/im_bigmap.js =================================================================== --- trunk/web/intermap/scripts/im_bigmap.js 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/intermap/scripts/im_bigmap.js 2007-09-18 13:04:19 UTC (rev 840) @@ -1006,10 +1006,16 @@ } function refreshNeeded(refreshmm, callback) -{ +{ if (autoRefresh) { + if($('im_mapImg')) imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox(), refreshmm, callback); + else // big one is not there: must we refresh the minimap? + if(refreshmm) + { + im_mm_refreshNeeded(callback); + } } else { Modified: trunk/web/intermap/scripts/im_extras.js =================================================================== --- trunk/web/intermap/scripts/im_extras.js 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/intermap/scripts/im_extras.js 2007-09-18 13:04:19 UTC (rev 840) @@ -11,6 +11,7 @@ ********************************************************************/ /* ## Called by the bottom toolbar +## Shows a list of configured map servers */ function im_addLayer() { @@ -57,13 +58,14 @@ t2.innerHTML = "Loading services from " +name; im.appendChild(t2); - imc_loadServerServices(id, im_servicesLoaded ); + imc_loadServerServices(id, im_servicesLoaded, "im_servicesSelected();"); } -function imc_loadServerServices(id, callback) +function imc_loadServerServices(id, callback, jscallback) { var url = '/intermap/srv/en/mapServers.getServices.embedded'; - var pars = 'mapserver='+id ; + var pars = 'mapserver='+id + +"&jscallback="+encodeURIComponent(jscallback); var myAjax = new Ajax.Request ( url, @@ -92,12 +94,14 @@ t2.innerHTML = "Loading services from given WMS server"; im.appendChild(t2); - imc_loadURLServices(url, -2, im_servicesLoaded ); + imc_loadURLServices(url, -2, im_servicesLoaded, "im_servicesSelected();" ); } -function imc_loadURLServices(url, type, callback) +function imc_loadURLServices(url, type, callback, jscallback) { - var pars = 'mapserver='+type+"&url="+url ; + var pars = 'mapserver='+type + +"&url="+encodeURIComponent(url) + +"&jscallback="+encodeURIComponent(jscallback); var myAjax = new Ajax.Request ( '/intermap/srv/en/mapServers.getServices.embedded', @@ -312,6 +316,112 @@ } /******************************************************************** +*** WMC +********************************************************************/ +/* +## Called by the bottom toolbar +*/ +function im_openWMCform() +{ + // setup WB + clearNode('im_whiteboard'); + var WB = $('im_whiteboard'); + + var wbtitle = im_createWBTitle("Export this map's Web Map Context"); //FIXME i18n + WB.appendChild(wbtitle); + + var closer = im_getWBCloser(); + WB.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + var div = document.createElement('div'); // main box + div.id = "im_createWMC"; + div.className = 'im_wbcontent'; + WB.appendChild(div); + + var pars="&width=" + im_bm_width + + "&height=" + im_bm_height; + + + var myAjax = new Ajax.Updater ( + 'im_createWMC', + '/intermap/srv/en/wmc.mailform', + { + method: 'get', + parameters: pars, + onFailure: im_load_error + } + ); + +} + +function im_requestWMC() +{ + var orient = $('pdf_orientation').value; + var psize = $('pdf_pagesize').value; + + var ptitle = $('pdf_title').value; + var pcopy = $('pdf_copyright').value; + + var bllist = $('pdf_layerlist').checked; + var bdetails = $('pdf_details').checked; + var bbbox = $('pdf_boundingbox').checked; + var bscale = $('pdf_scalebar').checked; + var barrow = $('pdf_arrow').checked; + + var pars = "orientation="+orient+ + "&pagesize="+psize+ + "&"+im_bm_getURLbbox(); + + if(ptitle) + pars += "&title="+ encodeURIComponent(ptitle); + if(pcopy) + pars += "©right="+ encodeURIComponent(pcopy); + + + if(bllist) + pars += "&layerlist=on"; + + if(bdetails) + pars += "&details=on"; + + if(bbbox) + pars += "&boundingbox=on"; + + if(bscale) + pars += "&scalebar=on"; + + if(barrow) + pars += "&arrow=on"; + + $('im_requestingpdf').show(); + $('im_requestpdf').hide(); + $('im_builtpdf').hide(); + + var myAjax = new Ajax.Request ( + '/intermap/srv/en/create.pdf', + { + method: 'get', + parameters: pars, + onSuccess: im_openPDF, + onFailure: im_load_error + } + ); + +} + +function im_openWMC(req) +{ + var url = req.responseXML.documentElement.getElementsByTagName('url')[0].firstChild.nodeValue; + + window.open(url); + + $('im_requestpdf').show(); + $('im_requestingpdf').hide(); + $('im_builtpdf').show(); +} + +/******************************************************************** *** Export image ********************************************************************/ /* Modified: trunk/web/intermap/xsl/im_get-services-embedded.xsl =================================================================== --- trunk/web/intermap/xsl/im_get-services-embedded.xsl 2007-09-17 22:07:50 UTC (rev 839) +++ trunk/web/intermap/xsl/im_get-services-embedded.xsl 2007-09-18 13:04:19 UTC (rev 840) @@ -44,8 +44,9 @@ <!-- <xsl:with-param name="buttons">--> <!-- <button class="content" onclick="document.form.action='{/root/gui/locService}/map.getMain';document.form.submit();"><xsl:value-of select="/root/gui/strings/cancel"/></button>-->   - <button class="content" onclick="im_servicesSelected();"><xsl:value-of select="/root/gui/strings/ok"/></button> - <!-- </xsl:with-param>--> +<!-- <button class="content" onclick="im_servicesSelected();"><xsl:value-of select="/root/gui/strings/ok"/></button>--> + <button class="content" onclick="{/root/response/jscallback}"><xsl:value-of select="/root/gui/strings/ok"/></button> + <!-- </xsl:with-param>--> <!-- </xsl:call-template>--> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <e_t...@us...> - 2007-09-19 00:03:03
|
Revision: 856 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=856&view=rev Author: e_tajariol Date: 2007-09-18 17:03:03 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Handling layers' legends. Modified Paths: -------------- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java trunk/web/intermap/scripts/im_ajax.js trunk/web/intermap/xsl/im_get-layers-embedded.xsl Modified: trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java =================================================================== --- trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-18 22:15:33 UTC (rev 855) +++ trunk/src/org/wfp/vam/intermap/kernel/map/MapMerger.java 2007-09-19 00:03:03 UTC (rev 856) @@ -22,9 +22,7 @@ import org.wfp.vam.intermap.kernel.GlobalTempFiles; import org.wfp.vam.intermap.kernel.map.images.ImageMerger; import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox; -import org.wfp.vam.intermap.kernel.map.mapServices.HttpClient; import org.wfp.vam.intermap.kernel.map.mapServices.MapService; -import org.wfp.vam.intermap.kernel.map.mapServices.ServiceException; public class MapMerger @@ -164,7 +162,8 @@ vRank.add(new Integer(order[i])); } - public Element toElementSimple() { + public Element toElementSimple() + { Element elServices = new Element("services"); // Add each contained service to the elServices, ordered by vRank @@ -172,12 +171,22 @@ Layer layer = _layers.get(idx); MapService s = layer.getService(); - elServices.addContent(new Element("layer") + String legend = null; + try + { + legend = s.getLegendUrl(); + } + catch (Exception e) {} + + Element eLayer = new Element("layer") .setAttribute("id", idx + "") .setAttribute("title", "" + s.getTitle()) .setAttribute("type", "" + s.getType()) - .setAttribute("transparency", "" + layer.getIntTransparency()) - ); + .setAttribute("transparency", "" + layer.getIntTransparency()); + if(legend != null) + eLayer.setAttribute("legend", legend); + + elServices.addContent(eLayer); } return elServices; @@ -719,89 +728,88 @@ return new BoundingBox(north, south, east, west); } - private class GetImageUrlThread extends Thread { - private MapService service; - private BoundingBox bb; - private int width, height; - private String url; - private boolean serviceError = false; // Flag used to detect if a serviceException was thrown by getImageUrl - private Element error; - - public void run() { sendRequest(); } - - private void sendRequest() { - try { - url = service.getImageUrl(bb, width, height); - } - catch (ServiceException e) { - // The service returned an error message (ArcIMS services only) - serviceError = true; - } - catch (Exception e) { - // Generic error +// private class GetImageUrlThread extends Thread { +// private MapService service; +// private BoundingBox bb; +// private int width, height; +// private String url; +// private boolean serviceError = false; // Flag used to detect if a serviceException was thrown by getImageUrl +// private Element error; +// +// public void run() { sendRequest(); } +// +// private void sendRequest() { +// try { +// url = service.getImageUrl(bb, width, height); +// } +// catch (ServiceException e) { +// // The service returned an error message (ArcIMS services only) +// serviceError = true; +// } +// catch (Exception e) { +// // Generic error +//// e.printStackTrace(); // DEBUG +// serviceError = true; +// url = null; +// } +// } +// +// public MapService getService() { return service; } +// +// public void setParameters(MapService service, BoundingBox bb, int width, int height) { +// this.service = service; +// this.bb = bb; +// this.width = width; +// this.height = height; +// } +// +// public String getUrl() throws ServiceException { +// if (serviceError) { +// throw new ServiceException(); +// } +// return url; +// } +// +// public Element getResponse() { return service.getLastResponse(); } +// +// } +// +// private class HttpThread extends Thread { +// private static final int BUF_LEN = 1024; +// +// private String stUrl; +// private String path; +// private HttpClient c; +// +// public void run() { connect(); } +// +// public void setParameters(String url) { stUrl = url; } +// +// public String getPath() { return path; } +// +// public HttpClient getHttpClient() { return c; } +// +// private void connect() { +// BufferedInputStream is = null; +// BufferedOutputStream os = null; +// +// try { +// c = new HttpClient(stUrl); +// File tf = GlobalTempFiles.getInstance().getFile(); +// c.getFile(tf); +// path = tf.getPath(); +// } +// catch (Exception e) { +// path = null; // e.printStackTrace(); // DEBUG - serviceError = true; - url = null; - } - } - - public MapService getService() { return service; } - - public void setParameters(MapService service, BoundingBox bb, int width, int height) { - this.service = service; - this.bb = bb; - this.width = width; - this.height = height; - } - - public String getUrl() throws ServiceException { - if (serviceError) { - throw new ServiceException(); - } - return url; - } - - public Element getResponse() { return service.getLastResponse(); } - - } - - private class HttpThread extends Thread { - private static final int BUF_LEN = 1024; - - private String stUrl; - private String path; - private HttpClient c; - - public void run() { connect(); } - - public void setParameters(String url) { stUrl = url; } - - public String getPath() { return path; } - - public HttpClient getHttpClient() { return c; } - - private void connect() { - BufferedInputStream is = null; - BufferedOutputStream os = null; - - try { - c = new HttpClient(stUrl); - File tf = GlobalTempFiles.getInstance().getFile(); - c.getFile(tf); - path = tf.getPath(); - } - catch (Exception e) { - path = null; - e.printStackTrace(); // DEBUG - } - finally { - // Close the streams - try { is.close(); } catch (Exception e) {} - try { os.close(); } catch (Exception e) {} - } - } - - } +// } +// finally { +// // Close the streams +// try { is.close(); } catch (Exception e) {} +// try { os.close(); } catch (Exception e) {} +// } +// } +// } } Modified: trunk/web/intermap/scripts/im_ajax.js =================================================================== --- trunk/web/intermap/scripts/im_ajax.js 2007-09-18 22:15:33 UTC (rev 855) +++ trunk/web/intermap/scripts/im_ajax.js 2007-09-19 00:03:03 UTC (rev 856) @@ -70,11 +70,53 @@ showLegend(activeLayerId); } -function showLegend(id) { - window.open('/intermap/srv/'+Env.lang+'/map.service.getLegend?id=' + id, 'dialog', 'HEIGHT=300,WIDTH=400,scrollbars=yes,toolbar=yes,status=yes,menubar=yes,location=yes,resizable=yes'); +function hideLegend() +{ + var div=$('im_legendPopup'); + if(div) + { + Event.stopObserving(div, 'click', hideLegend); + document.body.removeChild(div); + } } +function showLegend(url, btn) { +// window.open('/intermap/srv/'+Env.lang+'/map.service.getLegend?id=' + id, 'dialog', 'HEIGHT=300,WIDTH=400,scrollbars=yes,toolbar=yes,status=yes,menubar=yes,location=yes,resizable=yes'); + hideLegend(); + var div = document.createElement("div"); + div.id="im_legendPopup"; + div.style.position = "absolute"; + document.body.appendChild(div); + + var offset = Position.cumulativeOffset($(btn)); + var x = offset[0]; + var y = offset[1]; + + div.style.left=x+"px"; + div.style.top=y+"px"; + div.style.width="100px"; + div.style.height="50px"; +// div.style.border="solid black 1px"; +// div.style.background-color="064377"; + + var img = document.createElement("img"); +// img.src = "intermap/images/waiting.gif"; + img.src = url; + img.alt = "Loading legend..." + img.style.position = "absolute"; + img.style.border="solid black 1px"; + div.appendChild(img); + + Event.observe(div, 'click', hideLegend); + + + //window.open(url); + + +} + + /***************************************************************************** * * * Delete layer * Modified: trunk/web/intermap/xsl/im_get-layers-embedded.xsl =================================================================== --- trunk/web/intermap/xsl/im_get-layers-embedded.xsl 2007-09-18 22:15:33 UTC (rev 855) +++ trunk/web/intermap/xsl/im_get-layers-embedded.xsl 2007-09-19 00:03:03 UTC (rev 856) @@ -56,9 +56,13 @@ onclick="im_deleteLayer({@id})" src="/intermap/images/deleteLayer.png" title="{/root/gui/strings/removeLayer}"/> </xsl:if> - <img id="legend_{@id}" class="im_layerButton" - onclick="showLegend({@id})" - src="/intermap/images/legend.png" title="{/root/gui/strings/legend}"/> + + <xsl:if test="@legend"> + <img id="legend_{@id}" class="im_layerButton" + onclick="showLegend('{@legend}', legend_{@id});" + src="/intermap/images/legend.png" title="{/root/gui/strings/legend}"/> + </xsl:if> + <img id="showLayerMD_{@id}" class="im_layerButton" src="/intermap/images/metadata.png" title="{/root/gui/strings/metadata}"/> <select id="im_transp_{@id}" class="layerSelectTransp" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <blu...@us...> - 2007-09-24 16:14:25
|
Revision: 874 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=874&view=rev Author: bluenetdevteam Date: 2007-09-24 08:57:19 -0700 (Mon, 24 Sep 2007) Log Message: ----------- Fixes for dublin-core problems in 2.1 - flow on from dct: schema introduction Modified Paths: -------------- trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java trunk/web/geonetwork/xml/schemas/dublin-core/dc.xsd trunk/web/geonetwork/xml/schemas/dublin-core/loc/en/labels.xml trunk/web/geonetwork/xml/schemas/dublin-core/set-uuid.xsl trunk/web/geonetwork/xml/schemas/dublin-core/update-fixed-info.xsl Modified: trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/src/org/fao/geonet/kernel/schema/MetadataSchema.java 2007-09-24 15:57:19 UTC (rev 874) @@ -73,18 +73,10 @@ List<String> childType = hmElements.get(elem); if (childType == null) { // Check and see whether we can substitute another element from the - // list of substitution links - just process the arrayList until - // we find one that matches - ArrayList alSubsLink = (ArrayList) hmSubsLink.get(elem); - Logger.log("metadataSchema: checking subs for element "+elem+" parent "+parent); - if (alSubsLink != null) { - for (int i = 0;i< alSubsLink.size();i++) { - elem = (String) alSubsLink.get(i); - Logger.log(" -- substitute "+elem); - childType = hmElements.get(elem); - if (childType != null) continue; - } - } + // substitution link + elem = (String) hmSubsLink.get(elem); + Logger.log(" -- substitute "+elem); + childType = hmElements.get(elem); if (childType == null) throw new IllegalArgumentException("Mismatch between schema and xml: No type for 'element' : "+elem+" with parent "+parent); } @@ -157,13 +149,13 @@ //--- //--------------------------------------------------------------------------- - void addElement(String name, String type, ArrayList alValues, ArrayList alSubs, ArrayList alSubsLink) + void addElement(String name, String type, ArrayList alValues, ArrayList alSubs, String subLink) { // first just add the subs - because these are for global elements we // never have a clash because global elements are all in the same scope // and are thus unique if (alSubs != null && alSubs.size() > 0) hmSubs.put(name,alSubs); - if (alSubsLink != null && alSubsLink.size() > 0) hmSubsLink.put(name,alSubsLink); + if (subLink != null && subLink.length() > 0) hmSubsLink.put(name,subLink); List<String> exType = hmElements.get(name); Modified: trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java =================================================================== --- trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/src/org/fao/geonet/kernel/schema/SchemaLoader.java 2007-09-24 15:57:19 UTC (rev 874) @@ -100,8 +100,11 @@ { ee.type = (String) hmAbsElems.get(elem); - if (ee.type == null) - throw new IllegalArgumentException("Type is null for 'element' : " + ee.name); + if (ee.type == null) { + // If we don't have a type then insert with null and fix + // when all elements have been added to hmElements + Logger.log("Type is null for 'element' : "+ee.name+" which is part of substitution group with head element "+elem); + } } hmElements.put(ee.name, ee.type); @@ -117,6 +120,19 @@ String elem = (String) i.next(); String type = (String) hmElements.get(elem); + // fix any null types by back tracking through substitution links + // until we get a concrete type or die trying :-) + if (type == null) { + Logger.log("Searching for type for element "+elem); + type = recurseOnSubstitutionLinks(elem); + if (type == null) { + System.out.println("WARNING: Cannot find type for " +elem+": assuming string"); + type="xs:string"; + } else { + Logger.log("-- Recursive search returned "+type+" for element "+elem); + } + } + ArrayList elemRestr = (ArrayList) hmElemRestr.get(elem); ArrayList typeRestr = (ArrayList) hmTypeRestr.get(type); @@ -128,8 +144,8 @@ ArrayList elemSubs = (ArrayList) hmSubsNames.get(elem); if (elemSubs == null) elemSubs = new ArrayList(); - ArrayList elemSubsLink = (ArrayList) hmSubsLink.get(elem); - if (elemSubsLink == null) elemSubsLink = new ArrayList(); + String elemSubsLink = (String) hmSubsLink.get(elem); + if (elemSubsLink == null) elemSubsLink = ""; mds.addElement(elem, type, elemRestr, elemSubs, elemSubsLink); } @@ -259,7 +275,7 @@ { type = ee.type == null ? "string" : ee.type; - mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), new ArrayList()); + mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), ""); // 3. element is a choice element or an error } else { @@ -278,7 +294,7 @@ // create an mdt with the chosen name and process any nested choices createTypeAndResolveNestedChoices(mds,ee.alChoiceElems, baseChoiceName,baseChoiceNr); - mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), new ArrayList()); + mds.addElement(ee.name, type, new ArrayList(), new ArrayList(), ""); } @@ -291,10 +307,10 @@ ArrayList al = (ArrayList) hmSubsGrp.get(ee.ref); if (al == null) { - al = (ArrayList) hmSubsLink.get(ee.ref); + String subLink = (String) hmSubsLink.get(ee.ref); - if (al != null) { - Logger.log("WARNING: Adding abstract element "+ee.ref+" with substitution group "+al); + if (subLink != null) { + Logger.log("WARNING: Adding abstract element "+ee.ref+" with substitution group "+subLink); mdt.addRefElementWithNoType(ee.ref, ee.min, ee.max); } } @@ -311,7 +327,7 @@ Integer elementsAdded = recursivelyDealWithAbstractElements(mdtc,al); mdtc.setOrType(elementsAdded > 1); mds.addType(type,mdtc); - mds.addElement(ee.ref,type,new ArrayList(),new ArrayList(), new ArrayList()); + mds.addElement(ee.ref,type,new ArrayList(),new ArrayList(), ""); mdt.addElementWithType(ee.ref,type,ee.min,ee.max); } } @@ -330,6 +346,21 @@ //--------------------------------------------------------------------------- //--- + //--- Recurse on substitution links until we get a type that we can use + //--- + //--------------------------------------------------------------------------- + private String recurseOnSubstitutionLinks(String elemName) { + String elemLinkName = (String) hmSubsLink.get(elemName); + if (elemLinkName != null) { + String elemLinkType = (String) hmElements.get(elemLinkName); + if (elemLinkType != null) return elemLinkType; // found concrete type! + else recurseOnSubstitutionLinks(elemLinkName); // keep trying + } + return null; // Cannot find a type so return null + } + + //--------------------------------------------------------------------------- + //--- //--- Descend recursively to deal with nested choices (arggh) //--- //--------------------------------------------------------------------------- @@ -348,11 +379,11 @@ Integer newBaseNr = baseNr+1; createTypeAndResolveNestedChoices(mds,ee.alChoiceElems,baseName,newBaseNr); ee.name = ee.type = baseName+newBaseNr; - mds.addElement(ee.name,ee.type,new ArrayList(),new ArrayList(), new ArrayList()); + mds.addElement(ee.name,ee.type,new ArrayList(),new ArrayList(), ""); mdt.addElementWithType(ee.name, ee.type, ee.min, ee.max); } else { if (ee.name != null) { - mds.addElement(ee.name,ee.type,new ArrayList(),new ArrayList(), new ArrayList()); + mds.addElement(ee.name,ee.type,new ArrayList(),new ArrayList(),""); mdt.addElementWithType(ee.name, ee.type, ee.min, ee.max); } else { @@ -534,12 +565,11 @@ } al.add(ee); - ArrayList alLink = (ArrayList) hmSubsLink.get(ee.name); - if (alLink == null) { - alLink = new ArrayList(); - hmSubsLink.put(ee.name,alLink); + if (hmSubsLink.get(ee.name) != null) { + throw new IllegalArgumentException("Substitution link collision for : "+ee.name+" link to "+ee.substGroup); + } else { + hmSubsLink.put(ee.name,ee.substGroup); } - alLink.add(ee.substGroup); } if (ee.abstrElem) { Modified: trunk/web/geonetwork/xml/schemas/dublin-core/dc.xsd =================================================================== --- trunk/web/geonetwork/xml/schemas/dublin-core/dc.xsd 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/web/geonetwork/xml/schemas/dublin-core/dc.xsd 2007-09-24 15:57:19 UTC (rev 874) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns="http://purl.org/dc/elements/1.1/" + xmlns:dc="http://purl.org/dc/elements/1.1/" targetNamespace="http://purl.org/dc/elements/1.1/" elementFormDefault="qualified" attributeFormDefault="unqualified"> @@ -39,9 +39,12 @@ <xs:import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="xml.xsd"> - </xs:import> + schemaLocation="xml.xsd"/> + <xs:import namespace="http://purl.org/dc/terms/" + schemaLocation="dcterms.xsd"/> + + <xs:complexType name="SimpleLiteral"> <xs:annotation> <xs:documentation xml:lang="en"> @@ -75,23 +78,23 @@ </xs:complexType> - <xs:element name="any" type="SimpleLiteral" abstract="true"/> + <xs:element name="any" type="dc:SimpleLiteral" abstract="true"/> - <xs:element name="title" substitutionGroup="any"/> - <xs:element name="creator" substitutionGroup="any"/> - <xs:element name="subject" substitutionGroup="any"/> - <xs:element name="description" substitutionGroup="any"/> - <xs:element name="publisher" substitutionGroup="any"/> - <xs:element name="contributor" substitutionGroup="any"/> - <xs:element name="date" substitutionGroup="any"/> - <xs:element name="type" substitutionGroup="any"/> - <xs:element name="format" substitutionGroup="any"/> - <xs:element name="identifier" substitutionGroup="any"/> - <xs:element name="source" substitutionGroup="any"/> - <xs:element name="language" substitutionGroup="any"/> - <xs:element name="relation" substitutionGroup="any"/> - <xs:element name="coverage" substitutionGroup="any"/> - <xs:element name="rights" substitutionGroup="any"/> + <xs:element name="title" substitutionGroup="dc:any"/> + <xs:element name="creator" substitutionGroup="dc:any"/> + <xs:element name="subject" substitutionGroup="dc:any"/> + <xs:element name="description" substitutionGroup="dc:any"/> + <xs:element name="publisher" substitutionGroup="dc:any"/> + <xs:element name="contributor" substitutionGroup="dc:any"/> + <xs:element name="date" substitutionGroup="dc:any"/> + <xs:element name="type" substitutionGroup="dc:any"/> + <xs:element name="format" substitutionGroup="dc:any"/> + <xs:element name="identifier" substitutionGroup="dc:any"/> + <xs:element name="source" substitutionGroup="dc:any"/> + <xs:element name="language" substitutionGroup="dc:any"/> + <xs:element name="relation" substitutionGroup="dc:any"/> + <xs:element name="coverage" substitutionGroup="dc:any"/> + <xs:element name="rights" substitutionGroup="dc:any"/> <xs:group name="elementsGroup"> <xs:annotation> @@ -104,7 +107,7 @@ <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> - <xs:element ref="any"/> + <xs:element ref="dc:any"/> </xs:choice> </xs:sequence> </xs:group> @@ -118,7 +121,7 @@ </xs:annotation> <xs:choice> - <xs:group ref="elementsGroup"/> + <xs:group ref="dc:elementsGroup"/> </xs:choice> </xs:complexType> Modified: trunk/web/geonetwork/xml/schemas/dublin-core/loc/en/labels.xml =================================================================== --- trunk/web/geonetwork/xml/schemas/dublin-core/loc/en/labels.xml 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/web/geonetwork/xml/schemas/dublin-core/loc/en/labels.xml 2007-09-24 15:57:19 UTC (rev 874) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<labels xmlns:dc = "http://purl.org/dc/elements/1.1/"> +<labels xmlns:dc = "http://purl.org/dc/elements/1.1/" xmlns:dct = "http://purl.org/dc/terms/"> <!-- ==================================================== --> <element name="simpledc"> <label>Metadata</label> @@ -82,4 +82,54 @@ <description/> </element> <!-- ==================================================== --> + <element name="dct:modified"> + <label>Date Modified</label> + <description>Data metadata was modified</description> + </element> + <!-- ==================================================== --> + <element name="dct:abstract"> + <label>Abstract</label> + <description>A summary of the content of the resource.</description> + </element> + <!-- ==================================================== --> + <element name="dct:spatial"> + <label>Spatial</label> + <description>Spatial characteristics of the intellectual content of the resource.</description> + </element> + <!-- ==================================================== --> + <element name="dct:audience"> + <label>Audience</label> + <description>A class of entity for whom the resource is intended or useful.</description> + </element> + <!-- ==================================================== --> + <element name="dct:accrualMethod"> + <label>Accrual Method</label> + <description>The method by which items are added to a collection.</description> + </element> + <!-- ==================================================== --> + <element name="dct:accrualPeriodicity"> + <label>Accrual Periodicity</label> + <description>The frequency with which items are added to a collection.</description> + </element> + <!-- ==================================================== --> + <element name="dct:accrualPolicy"> + <label>Accrual Policy</label> + <description>The policy governing the addition of items to a collection.</description> + </element> + <!-- ==================================================== --> + <element name="dct:instructionalMethod"> + <label>Instructional Method</label> + <description>A process, used to engender knowledge, attitudes and skills, that the resource is designed to support.</description> + </element> + <!-- ==================================================== --> + <element name="dct:provenance"> + <label>Provenance</label> + <description>A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity and interpretation.</description> + </element> + <!-- ==================================================== --> + <element name="dct:rightsHolder"> + <label>Rights Holder</label> + <description>A person or organization owning or managing rights over the resource.</description> + </element> + <!-- ==================================================== --> </labels> Modified: trunk/web/geonetwork/xml/schemas/dublin-core/set-uuid.xsl =================================================================== --- trunk/web/geonetwork/xml/schemas/dublin-core/set-uuid.xsl 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/web/geonetwork/xml/schemas/dublin-core/set-uuid.xsl 2007-09-24 15:57:19 UTC (rev 874) @@ -36,6 +36,13 @@ <xsl:apply-templates select="dct:abstract"/> <xsl:apply-templates select="dct:modified"/> <xsl:apply-templates select="dct:spatial"/> + <xsl:apply-templates select="dct:audience"/> + <xsl:apply-templates select="dct:accrualMethod"/> + <xsl:apply-templates select="dct:accrualPeriodicity"/> + <xsl:apply-templates select="dct:accrualPolicy"/> + <xsl:apply-templates select="dct:instructionalMethod"/> + <xsl:apply-templates select="dct:provenance"/> + <xsl:apply-templates select="dct:rightsHolder"/> </xsl:copy> </xsl:template> Modified: trunk/web/geonetwork/xml/schemas/dublin-core/update-fixed-info.xsl =================================================================== --- trunk/web/geonetwork/xml/schemas/dublin-core/update-fixed-info.xsl 2007-09-21 14:15:02 UTC (rev 873) +++ trunk/web/geonetwork/xml/schemas/dublin-core/update-fixed-info.xsl 2007-09-24 15:57:19 UTC (rev 874) @@ -51,6 +51,13 @@ <xsl:apply-templates select="dct:abstract"/> <dct:modified><xsl:value-of select="/root/env/changeDate"/></dct:modified> <xsl:apply-templates select="dct:spatial"/> + <xsl:apply-templates select="dct:audience"/> + <xsl:apply-templates select="dct:accrualMethod"/> + <xsl:apply-templates select="dct:accrualPeriodicity"/> + <xsl:apply-templates select="dct:accrualPolicy"/> + <xsl:apply-templates select="dct:instructionalMethod"/> + <xsl:apply-templates select="dct:provenance"/> + <xsl:apply-templates select="dct:rightsHolder"/> </xsl:copy> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2007-10-06 15:35:19
|
Revision: 886 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=886&view=rev Author: acarboni Date: 2007-10-06 08:35:21 -0700 (Sat, 06 Oct 2007) Log Message: ----------- Added OAI-PMH harvesting type, both client and server Added Paths: ----------- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Harvester.java trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhHarvester.java trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhParams.java trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/RecordInfo.java trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Search.java trunk/src/org/fao/geonet/kernel/oaipmh/ trunk/src/org/fao/geonet/kernel/oaipmh/Lib.java trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhDispatcher.java trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhService.java trunk/src/org/fao/geonet/kernel/oaipmh/services/ trunk/src/org/fao/geonet/kernel/oaipmh/services/GetRecord.java trunk/src/org/fao/geonet/kernel/oaipmh/services/Identify.java trunk/src/org/fao/geonet/kernel/oaipmh/services/ListIdentifiers.java trunk/src/org/fao/geonet/kernel/oaipmh/services/ListMetadataFormats.java trunk/src/org/fao/geonet/kernel/oaipmh/services/ListRecords.java trunk/src/org/fao/geonet/kernel/oaipmh/services/ListSets.java trunk/src/org/fao/geonet/kernel/oaipmh/services/SearchResult.java trunk/src/org/fao/geonet/services/main/OaiPmhDispatcher.java trunk/src/org/fao/oaipmh/ trunk/src/org/fao/oaipmh/OaiPmh.java trunk/src/org/fao/oaipmh/exceptions/ trunk/src/org/fao/oaipmh/exceptions/BadArgumentException.java trunk/src/org/fao/oaipmh/exceptions/BadResumptionTokenException.java trunk/src/org/fao/oaipmh/exceptions/BadVerbException.java trunk/src/org/fao/oaipmh/exceptions/CannotDisseminateFormatException.java trunk/src/org/fao/oaipmh/exceptions/IdDoesNotExistException.java trunk/src/org/fao/oaipmh/exceptions/NoMetadataFormatsException.java trunk/src/org/fao/oaipmh/exceptions/NoRecordsMatchException.java trunk/src/org/fao/oaipmh/exceptions/NoSetHierarchyException.java trunk/src/org/fao/oaipmh/exceptions/OaiPmhException.java trunk/src/org/fao/oaipmh/requests/ trunk/src/org/fao/oaipmh/requests/AbstractRequest.java trunk/src/org/fao/oaipmh/requests/GetRecordRequest.java trunk/src/org/fao/oaipmh/requests/IdentifyRequest.java trunk/src/org/fao/oaipmh/requests/ListIdentifiersRequest.java trunk/src/org/fao/oaipmh/requests/ListMetadataFormatsRequest.java trunk/src/org/fao/oaipmh/requests/ListRecordsRequest.java trunk/src/org/fao/oaipmh/requests/ListRequest.java trunk/src/org/fao/oaipmh/requests/ListSetsRequest.java trunk/src/org/fao/oaipmh/requests/Transport.java trunk/src/org/fao/oaipmh/responses/ trunk/src/org/fao/oaipmh/responses/AbstractResponse.java trunk/src/org/fao/oaipmh/responses/GetRecordResponse.java trunk/src/org/fao/oaipmh/responses/Header.java trunk/src/org/fao/oaipmh/responses/IdentifyResponse.java trunk/src/org/fao/oaipmh/responses/ListIdentifiersResponse.java trunk/src/org/fao/oaipmh/responses/ListMetadataFormatsResponse.java trunk/src/org/fao/oaipmh/responses/ListRecordsResponse.java trunk/src/org/fao/oaipmh/responses/ListResponse.java trunk/src/org/fao/oaipmh/responses/ListSetsResponse.java trunk/src/org/fao/oaipmh/responses/MetadataFormat.java trunk/src/org/fao/oaipmh/responses/Record.java trunk/src/org/fao/oaipmh/responses/ResumptionToken.java trunk/src/org/fao/oaipmh/responses/SetInfo.java trunk/src/org/fao/oaipmh/server/ trunk/src/org/fao/oaipmh/server/OaiPmhFactory.java trunk/src/org/fao/oaipmh/util/ trunk/src/org/fao/oaipmh/util/Lib.java trunk/src/org/fao/oaipmh/util/Xml.java trunk/web/geonetwork/xml/schemas/dublin-core/convert/ trunk/web/geonetwork/xml/schemas/dublin-core/convert/oai-dc.xsl trunk/web/geonetwork/xml/schemas/fgdc-std/convert/ trunk/web/geonetwork/xml/schemas/fgdc-std/convert/oai-dc.xsl trunk/web/geonetwork/xml/schemas/iso19115/convert/ trunk/web/geonetwork/xml/schemas/iso19115/convert/oai-dc.xsl trunk/web/geonetwork/xml/schemas/iso19139/convert/ trunk/web/geonetwork/xml/schemas/iso19139/convert/oai-dc.xsl trunk/web/geonetwork/xml/validation/oai/ trunk/web/geonetwork/xml/validation/oai/OAI-PMH.xsd trunk/web/geonetwork/xml/validation/oai/dc/ trunk/web/geonetwork/xml/validation/oai/dc/oai_dc.xsd trunk/web/geonetwork/xml/validation/oai/dc/simpledc20021212.xsd trunk/web/geonetwork/xml/validation/oai/dc/xml.xsd Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Harvester.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Harvester.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Harvester.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,476 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.oaipmh; + +import java.io.File; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import jeeves.exceptions.OperationAbortedEx; +import jeeves.interfaces.Logger; +import jeeves.resources.dbms.Dbms; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Xml; +import org.fao.geonet.GeonetContext; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.DataManager; +import org.fao.geonet.kernel.harvest.harvester.CategoryMapper; +import org.fao.geonet.kernel.harvest.harvester.GroupMapper; +import org.fao.geonet.kernel.harvest.harvester.Privileges; +import org.fao.geonet.kernel.harvest.harvester.UUIDMapper; +import org.fao.geonet.util.ISODate; +import org.fao.oaipmh.OaiPmh; +import org.fao.oaipmh.exceptions.NoRecordsMatchException; +import org.fao.oaipmh.requests.GetRecordRequest; +import org.fao.oaipmh.requests.ListIdentifiersRequest; +import org.fao.oaipmh.requests.Transport; +import org.fao.oaipmh.responses.GetRecordResponse; +import org.fao.oaipmh.responses.Header; +import org.fao.oaipmh.responses.ListIdentifiersResponse; +import org.jdom.Element; +import org.jdom.JDOMException; + +//============================================================================= + +class Harvester +{ + //-------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //-------------------------------------------------------------------------- + + public Harvester(Logger log, ServiceContext context, Dbms dbms, OaiPmhParams params) + { + this.log = log; + this.context= context; + this.dbms = dbms; + this.params = params; + + result = new OaiPmhResult(); + + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + dataMan = gc.getDataManager(); + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public OaiPmhResult harvest() throws Exception + { + ListIdentifiersRequest req = new ListIdentifiersRequest(); + req.setValidationSchema(new File(context.getAppPath() + Geonet.SchemaPath.OAI_PMH)); + + Transport t = req.getTransport(); + t.setUrl(new URL(params.url)); + + if (params.useAccount) + t.setCredentials(params.username, params.password); + + //--- perform all searches + + Set<RecordInfo> records = new HashSet<RecordInfo>(); + + for(Search s : params.getSearches()) + records.addAll(search(req, s)); + + if (params.isSearchEmpty()) + records.addAll(search(req, Search.createEmptySearch())); + + log.info("Total records processed in all searches :"+ records.size()); + + //--- align local node + + if (records.size() != 0) + align(t, records); + + return result; + } + + //--------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //--------------------------------------------------------------------------- + + private Set<RecordInfo> search(ListIdentifiersRequest req, Search s) throws OperationAbortedEx + { + //--- setup search parameters + + if (s.from.length() != 0) req.setFrom(new ISODate(s.from)); + else req.setFrom(null); + + if (s.until.length() != 0) req.setUntil(new ISODate(s.from)); + else req.setUntil(null); + + if (s.set.length() != 0) req.setSet(s.set); + else req.setSet(null); + + req.setMetadataPrefix(s.prefix); + + //--- execute request and loop on response + + Set<RecordInfo> records = new HashSet<RecordInfo>(); + + log.info("Searching on : "+ params.name); + + try + { + ListIdentifiersResponse response = req.execute(); + + while (response.hasNext()) + { + Header h = response.next(); + + if (!h.isDeleted()) + records.add(new RecordInfo(h, s.prefix)); + } + + log.info("Records added to result list : "+ records.size()); + + return records; + } + catch(NoRecordsMatchException e) + { + //--- return gracefully + return records; + } + + catch(Exception e) + { + log.warning("Raised exception when searching : "+ e); + throw new OperationAbortedEx("Raised exception when searching", e); + } + } + + //--------------------------------------------------------------------------- + + private void align(Transport t, Set<RecordInfo> records) throws Exception + { + log.info("Start of alignment for : "+ params.name); + + //----------------------------------------------------------------------- + //--- retrieve all local categories and groups + //--- retrieve harvested uuids for given harvesting node + + localCateg = new CategoryMapper(dbms); + localGroups= new GroupMapper(dbms); + localUuids = new UUIDMapper(dbms, params.uuid); + dbms.commit(); + + //----------------------------------------------------------------------- + //--- remove old metadata + + for (String uuid : localUuids.getUUIDs()) + if (!exists(records, uuid)) + { + String id = localUuids.getID(uuid); + + log.debug(" - Removing old metadata with local id:"+ id); + dataMan.deleteMetadata(dbms, id); + dbms.commit(); + result.locallyRemoved++; + } + + //----------------------------------------------------------------------- + //--- insert/update new metadata + + for(RecordInfo ri : records) + { + result.total++; + + String id = localUuids.getID(ri.id); + + if (id == null) addMetadata(t, ri); + else updateMetadata(t, ri, id); + } + + log.info("End of alignment for : "+ params.name); + } + + //-------------------------------------------------------------------------- + /** Return true if the uuid is present in the remote records */ + + private boolean exists(Set<RecordInfo> records, String uuid) + { + for(RecordInfo ri : records) + if (uuid.equals(ri.id)) + return true; + + return false; + } + + //-------------------------------------------------------------------------- + //--- + //--- Private methods : addMetadata + //--- + //-------------------------------------------------------------------------- + + private void addMetadata(Transport t, RecordInfo ri) throws Exception + { + Element md = retrieveMetadata(t, ri); + + if (md == null) + return; + + //--- schema handled check already done + + String schema = dataMan.autodetectSchema(md); + + log.debug(" - Adding metadata with remote id : "+ ri.id); + + String id = dataMan.insertMetadataExt(dbms, schema, md, context.getSerialFactory(), params.uuid, + ri.changeDate.toString(), ri.changeDate.toString(), ri.id, 1, null); + + int iId = Integer.parseInt(id); + + dataMan.setTemplate(dbms, iId, "n", null); + dataMan.setHarvested(dbms, iId, params.uuid, null); + + addPrivileges(id); + addCategories(id); + + dbms.commit(); + dataMan.indexMetadata(dbms, id); + result.added++; + } + + //-------------------------------------------------------------------------- + + private Element retrieveMetadata(Transport t, RecordInfo ri) + { + try + { + log.debug(" - Getting remote metadata with id : "+ ri.id); + + GetRecordRequest req = new GetRecordRequest(); + req.setValidationSchema(new File(context.getAppPath() + Geonet.SchemaPath.OAI_PMH)); + req.setTransport(t); + req.setIdentifier(ri.id); + req.setMetadataPrefix(ri.prefix); + + GetRecordResponse res = req.execute(); + + Element md = res.getRecord().getMetadata(); + + log.debug(" - Record got:\n"+ Xml.getString(md)); + + if (isOaiDc(md)) + { + log.debug(" - Converting oai_dc to dublin core"); + md = toDublinCore(md); + + if (md == null) + return null; + } + + String schema = dataMan.autodetectSchema(md); + + if (schema == null) + { + log.warning("Skipping metadata with unknown schema. Remote id : "+ ri.id); + result.unknownSchema++; + } + else + { + if (!params.validate || validates(schema, md)) + return (Element) md.detach(); + + log.warning("Skipping metadata that does not validate. Remote id : "+ ri.id); + result.doesNotValidate++; + } + } + + catch(JDOMException e) + { + log.warning("Skipping metadata with bad XML format. Remote id : "+ ri.id); + result.badFormat++; + } + + catch(Exception e) + { + log.warning("Raised exception while getting metadata file : "+ e); + result.unretrievable++; + } + + //--- we don't raise any exception here. Just try to go on + return null; + } + + //-------------------------------------------------------------------------- + + private boolean isOaiDc(Element md) + { + return (md.getName().equals("dc")) && (md.getNamespace().equals(OaiPmh.Namespaces.OAI_DC)); + } + + //-------------------------------------------------------------------------- + + private Element toDublinCore(Element md) + { + String styleSheet = context.getAppPath() +"conversion/oai_dc-to-dublin-core/main.xsl"; + + try + { + return Xml.transform(md, styleSheet); + } + catch (Exception e) + { + log.warning("Cannot convert oai_dc to dublin core : "+ e); + return null; + } + } + + //-------------------------------------------------------------------------- + + private boolean validates(String schema, Element md) + { + try + { + dataMan.validate(schema, md); + return true; + } + catch (Exception e) + { + return false; + } + } + + //-------------------------------------------------------------------------- + //--- Categories + //-------------------------------------------------------------------------- + + private void addCategories(String id) throws Exception + { + for(String catId : params.getCategories()) + { + String name = localCateg.getName(catId); + + if (name == null) + log.debug(" - Skipping removed category with id:"+ catId); + else + { + log.debug(" - Setting category : "+ name); + dataMan.setCategory(dbms, id, catId); + } + } + } + + //-------------------------------------------------------------------------- + //--- Privileges + //-------------------------------------------------------------------------- + + private void addPrivileges(String id) throws Exception + { + for (Privileges priv : params.getPrivileges()) + { + String name = localGroups.getName(priv.getGroupId()); + + if (name == null) + log.debug(" - Skipping removed group with id:"+ priv.getGroupId()); + else + { + log.debug(" - Setting privileges for group : "+ name); + + for (int opId: priv.getOperations()) + { + name = dataMan.getAccessManager().getPrivilegeName(opId); + + //--- allow only: view, dynamic, featured + if (opId == 0 || opId == 5 || opId == 6) + { + log.debug(" --> "+ name); + dataMan.setOperation(dbms, id, priv.getGroupId(), opId +""); + } + else + log.debug(" --> "+ name +" (skipped)"); + } + } + } + } + + //-------------------------------------------------------------------------- + //--- + //--- Private methods : updateMetadata + //--- + //-------------------------------------------------------------------------- + + private void updateMetadata(Transport t, RecordInfo ri, String id) throws Exception + { + String date = localUuids.getChangeDate(ri.id); + + if (!ri.isMoreRecentThan(date)) + { + log.debug(" - Metadata XML not changed for remote id : "+ ri.id); + result.unchanged++; + } + else + { + log.debug(" - Updating local metadata for remote id : "+ ri.id); + + Element md = retrieveMetadata(t, ri); + + if (md == null) + return; + + dataMan.updateMetadataExt(dbms, id, md, ri.changeDate.toString()); + + //--- the administrator could change privileges and categories using the + //--- web interface so we have to re-set both + + dbms.execute("DELETE FROM OperationAllowed WHERE metadataId=?", Integer.parseInt(id)); + addPrivileges(id); + + dbms.execute("DELETE FROM MetadataCateg WHERE metadataId=?", Integer.parseInt(id)); + addCategories(id); + + dbms.commit(); + dataMan.indexMetadata(dbms, id); + result.updated++; + } + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + private Logger log; + private ServiceContext context; + private Dbms dbms; + private OaiPmhParams params; + private DataManager dataMan; + private CategoryMapper localCateg; + private GroupMapper localGroups; + private UUIDMapper localUuids; + private OaiPmhResult result; +} + +//============================================================================= + + Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhHarvester.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhHarvester.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhHarvester.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,246 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.oaipmh; + +import java.io.File; +import java.sql.SQLException; +import java.util.UUID; +import jeeves.exceptions.BadInputEx; +import jeeves.interfaces.Logger; +import jeeves.resources.dbms.Dbms; +import jeeves.server.context.ServiceContext; +import jeeves.server.resources.ResourceManager; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.harvest.harvester.AbstractHarvester; +import org.fao.geonet.kernel.harvest.harvester.AbstractParams; +import org.fao.geonet.lib.Lib; +import org.jdom.Element; + +//============================================================================= + +public class OaiPmhHarvester extends AbstractHarvester +{ + //-------------------------------------------------------------------------- + //--- + //--- Static init + //--- + //-------------------------------------------------------------------------- + + public static void init(ServiceContext context) throws Exception {} + + //-------------------------------------------------------------------------- + //--- + //--- Harvesting type + //--- + //-------------------------------------------------------------------------- + + public String getType() { return "oaipmh"; } + + //-------------------------------------------------------------------------- + //--- + //--- Init + //--- + //-------------------------------------------------------------------------- + + protected void doInit(Element node) throws BadInputEx + { + params = new OaiPmhParams(dataMan); + params.create(node); + } + + //--------------------------------------------------------------------------- + //--- + //--- doDestroy + //--- + //--------------------------------------------------------------------------- + + protected void doDestroy(Dbms dbms) throws SQLException + { + File icon = new File(context.getAppPath() +"images/logos", params.uuid +".gif"); + + icon.delete(); + Lib.sources.delete(dbms, params.uuid); + } + + //--------------------------------------------------------------------------- + //--- + //--- Add + //--- + //--------------------------------------------------------------------------- + + protected String doAdd(Dbms dbms, Element node) throws BadInputEx, SQLException + { + params = new OaiPmhParams(dataMan); + + //--- retrieve/initialize information + params.create(node); + + //--- force the creation of a new uuid + params.uuid = UUID.randomUUID().toString(); + + String id = settingMan.add(dbms, "harvesting", "node", getType()); + + storeNode(dbms, params, "id:"+id); + Lib.sources.update(dbms, params.uuid, params.name, true); + Lib.sources.copyLogo(context, "/images/harvesting/"+ params.icon, params.uuid); + + return id; + } + + //--------------------------------------------------------------------------- + //--- + //--- Update + //--- + //--------------------------------------------------------------------------- + + protected void doUpdate(Dbms dbms, String id, Element node) + throws BadInputEx, SQLException + { + OaiPmhParams copy = params.copy(); + + //--- update variables + copy.update(node); + + String path = "harvesting/id:"+ id; + + settingMan.removeChildren(dbms, path); + + //--- update database + storeNode(dbms, copy, path); + + //--- we update a copy first because if there is an exception CswParams + //--- could be half updated and so it could be in an inconsistent state + + Lib.sources.update(dbms, copy.uuid, copy.name, true); + Lib.sources.copyLogo(context, "/images/harvesting/"+ copy.icon, copy.uuid); + + params = copy; + } + + //--------------------------------------------------------------------------- + + protected void storeNodeExtra(Dbms dbms, AbstractParams p, String path, + String siteId, String optionsId) throws SQLException + { + OaiPmhParams params = (OaiPmhParams) p; + + settingMan.add(dbms, "id:"+siteId, "url", params.url); + settingMan.add(dbms, "id:"+siteId, "icon", params.icon); + + settingMan.add(dbms, "id:"+optionsId, "validate", params.validate); + + //--- store search nodes + + for (Search s : params.getSearches()) + { + String searchID = settingMan.add(dbms, path, "search", ""); + + settingMan.add(dbms, "id:"+searchID, "from", s.from); + settingMan.add(dbms, "id:"+searchID, "until", s.until); + settingMan.add(dbms, "id:"+searchID, "set", s.set); + settingMan.add(dbms, "id:"+searchID, "prefix", s.prefix); + settingMan.add(dbms, "id:"+searchID, "stylesheet", s.stylesheet); + } + } + + //--------------------------------------------------------------------------- + //--- + //--- AbstractParameters + //--- + //--------------------------------------------------------------------------- + + protected AbstractParams getParams() { return params; } + + //--------------------------------------------------------------------------- + //--- + //--- AddInfo + //--- + //--------------------------------------------------------------------------- + + protected void doAddInfo(Element node) + { + //--- if the harvesting is not started yet, we don't have any info + + if (result == null) + return; + + //--- ok, add proper info + + Element info = node.getChild("info"); + Element res = new Element("result"); + + add(res, "total", result.total); + add(res, "added", result.added); + add(res, "updated", result.updated); + add(res, "unchanged", result.unchanged); + add(res, "unknownSchema", result.unknownSchema); + add(res, "removed", result.locallyRemoved); + add(res, "unretrievable", result.unretrievable); + add(res, "badFormat", result.badFormat); + add(res, "doesNotValidate",result.doesNotValidate); + + info.addContent(res); + } + + //--------------------------------------------------------------------------- + //--- + //--- Harvest + //--- + //--------------------------------------------------------------------------- + + protected void doHarvest(Logger log, ResourceManager rm) throws Exception + { + Dbms dbms = (Dbms) rm.open(Geonet.Res.MAIN_DB); + + Harvester h = new Harvester(log, context, dbms, params); + result = h.harvest(); + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + private OaiPmhParams params; + private OaiPmhResult result; +} + +//============================================================================= + +class OaiPmhResult +{ + public int total; + public int added; + public int updated; + public int unchanged; + public int locallyRemoved; + public int unknownSchema; + public int unretrievable; + public int badFormat; + public int doesNotValidate; +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhParams.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhParams.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/OaiPmhParams.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,164 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.oaipmh; + +import java.util.ArrayList; +import jeeves.exceptions.BadInputEx; +import jeeves.utils.Util; +import org.fao.geonet.kernel.DataManager; +import org.fao.geonet.kernel.harvest.harvester.AbstractParams; +import org.jdom.Element; + +//============================================================================= + +public class OaiPmhParams extends AbstractParams +{ + //-------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //-------------------------------------------------------------------------- + + public OaiPmhParams(DataManager dm) + { + super(dm); + } + + //--------------------------------------------------------------------------- + //--- + //--- Create : called when a new entry must be added. Reads values from the + //--- provided entry, providing default values + //--- + //--------------------------------------------------------------------------- + + public void create(Element node) throws BadInputEx + { + super.create(node); + + Element site = node.getChild("site"); + Element options = node.getChild("options"); + Element searches = node.getChild("searches"); + + url = Util.getParam(site, "url", ""); + icon = Util.getParam(site, "icon", ""); + + validate = Util.getParam(options, "validate", false); + + addSearches(searches); + } + + //--------------------------------------------------------------------------- + //--- + //--- Update : called when an entry has changed and variables must be updated + //--- + //--------------------------------------------------------------------------- + + public void update(Element node) throws BadInputEx + { + super.update(node); + + Element site = node.getChild("site"); + Element options = node.getChild("options"); + Element searches = node.getChild("searches"); + + url = Util.getParam(site, "url", url); + icon = Util.getParam(site, "icon", icon); + + validate = Util.getParam(options, "validate", validate); + + //--- if some search queries are given, we drop the previous ones and + //--- set these new ones + + if (searches != null) + addSearches(searches); + } + + //--------------------------------------------------------------------------- + //--- + //--- Other API methods + //--- + //--------------------------------------------------------------------------- + + public Iterable<Search> getSearches() { return alSearches; } + + //--------------------------------------------------------------------------- + + public boolean isSearchEmpty() { return alSearches.isEmpty(); } + + //--------------------------------------------------------------------------- + + public OaiPmhParams copy() + { + OaiPmhParams copy = new OaiPmhParams(dm); + copyTo(copy); + + copy.url = url; + copy.icon = icon; + + copy.validate = validate; + + for (Search s : alSearches) + copy.alSearches.add(s.copy()); + + return copy; + } + + //--------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //--------------------------------------------------------------------------- + + private void addSearches(Element searches) throws BadInputEx + { + alSearches.clear(); + + if (searches == null) + return; + + for (Object o : searches.getChildren("search")) + { + Element search = (Element) o; + + alSearches.add(new Search(search)); + } + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + public String url; + public String icon; + + public boolean validate; + + private ArrayList<Search> alSearches = new ArrayList<Search>(); +} + +//============================================================================= + + Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/RecordInfo.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/RecordInfo.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/RecordInfo.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,92 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.oaipmh; + +import org.fao.geonet.util.ISODate; +import org.fao.oaipmh.responses.Header; + +//============================================================================= + +public class RecordInfo +{ + //--------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //--------------------------------------------------------------------------- + + public RecordInfo(Header h, String mdPrefix) + { + id = h.getIdentifier(); + changeDate = h.getDateStamp(); + prefix = mdPrefix; + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public int hashCode() { return id.hashCode(); } + + //--------------------------------------------------------------------------- + + public boolean isMoreRecentThan(String localChangeDate) + { + ISODate localDate = new ISODate(localChangeDate); + + //--- accept if remote date is greater than local date + + return (changeDate.sub(localDate) > 0); + } + + //--------------------------------------------------------------------------- + + public boolean equals(Object o) + { + if (o instanceof RecordInfo) + { + RecordInfo ri = (RecordInfo) o; + + return id.equals(ri.id); + } + + return false; + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + public String id; + public ISODate changeDate; + public String prefix; + +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Search.java =================================================================== --- trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Search.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/harvest/harvester/oaipmh/Search.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,144 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.harvest.harvester.oaipmh; + +import jeeves.exceptions.BadInputEx; +import jeeves.exceptions.BadParameterEx; +import jeeves.utils.Util; +import org.fao.geonet.util.ISODate; +import org.jdom.Element; + +//============================================================================= + +class Search +{ + //--------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //--------------------------------------------------------------------------- + + private Search() {} + + //--------------------------------------------------------------------------- + + public Search(Element search) throws BadInputEx + { + from = Util.getParam(search, "from", ""); + until = Util.getParam(search, "until", ""); + set = Util.getParam(search, "set", ""); + prefix = Util.getParam(search, "prefix", "oai_dc"); + stylesheet = Util.getParam(search, "stylesheet", ""); + + //--- check from parameter + + ISODate fromDate = null; + ISODate untilDate= null; + + try + { + if (from != "") + { + fromDate = new ISODate(from); + from = fromDate.getDate(); + } + + } + catch(Exception e) + { + throw new BadParameterEx("from", from); + } + + //--- check until parameter + + try + { + if (until != "") + { + untilDate = new ISODate(until); + until = untilDate.getDate(); + } + } + catch(Exception e) + { + throw new BadParameterEx("until", until); + } + + //--- check from <= until + + if (fromDate != null && untilDate != null) + if (fromDate.sub(untilDate) > 0) + throw new BadParameterEx("from greater than until", from +">"+ until); + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public Search copy() + { + Search s = new Search(); + + s.from = from; + s.until = until; + s.set = set; + s.prefix = prefix; + s.stylesheet = stylesheet; + + return s; + } + + //--------------------------------------------------------------------------- + + public static Search createEmptySearch() throws BadInputEx + { + Search s = new Search(); + + s.from = ""; + s.until = ""; + s.set = ""; + s.prefix = "oai_dc"; + s.stylesheet = ""; + + return s; + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + public String from; + public String until; + public String set; + public String prefix; + public String stylesheet; +} + +//============================================================================= + + Added: trunk/src/org/fao/geonet/kernel/oaipmh/Lib.java =================================================================== --- trunk/src/org/fao/geonet/kernel/oaipmh/Lib.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/oaipmh/Lib.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,179 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.oaipmh; + +import java.util.ArrayList; +import java.util.List; +import jeeves.constants.Jeeves; +import jeeves.resources.dbms.Dbms; +import jeeves.server.ServiceConfig; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Xml; +import org.fao.geonet.GeonetContext; +import org.fao.geonet.constants.Edit; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.search.MetaSearcher; +import org.fao.geonet.kernel.search.SearchManager; +import org.fao.geonet.kernel.setting.SettingInfo; +import org.fao.oaipmh.exceptions.IdDoesNotExistException; +import org.fao.oaipmh.exceptions.OaiPmhException; +import org.jdom.Element; + +//============================================================================= + +public class Lib +{ + public static final int MAX_RECORDS = 10; + + public static final String SESSION_OBJECT = "oai-list-records-result"; + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public static String getMetadataSchema(ServiceContext context, String uuid) throws Exception + { + Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); + + String query = "SELECT schemaId FROM Metadata WHERE uuid=?"; + + List list = dbms.select(query, uuid).getChildren(); + + if (list.size() == 0) + throw new IdDoesNotExistException(uuid); + + Element elem = (Element) list.get(0); + + return elem.getChildText("schemaid"); + } + + //--------------------------------------------------------------------------- + + public static String getSchemaUrl(ServiceContext context, String relativePath) + { + SettingInfo si = new SettingInfo(context); + + return si.getSiteUrl() + context.getBaseUrl() +"/"+ relativePath; + } + + //-------------------------------------------------------------------------- + + public static Element toOaiDC(String schema, Element md, String uuid, + String changeDate, String appPath) throws Exception + { + //--- setup environment + + Element env = new Element("env"); + + env.addContent(new Element("uuid") .setText(uuid)); + env.addContent(new Element("changeDate").setText(changeDate)); + + //--- setup root element + + Element root = new Element("root"); + root.addContent(md); + root.addContent(env); + + //--- do an XSL transformation + + String styleSheet = appPath +"xml/schemas/"+schema+"/convert/oai-dc.xsl"; + + return Xml.transform(root, styleSheet); + } + + //--------------------------------------------------------------------------- + + public static List<Integer> search(ServiceContext context, Element params) throws Exception + { + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + SearchManager sm = gc.getSearchmanager(); + + MetaSearcher searcher = sm.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE); + + context.debug("Searching with params:\n"+ Xml.getString(params)); + + searcher.search(context, params, dummyConfig); + + params.addContent(new Element("fast").setText("true")); + params.addContent(new Element("from").setText("1")); + params.addContent(new Element("to").setText(searcher.getSize() +"")); + + context.info("Records found : "+ searcher.getSize()); + + Element records = searcher.present(context, params, dummyConfig); + + records.getChild("summary").detach(); + + List<Integer> result = new ArrayList<Integer>(); + + for (Object o : records.getChildren()) + { + Element rec = (Element) o; + Element info = rec.getChild("info", Edit.NAMESPACE); + + result.add(Integer.parseInt(info.getChildText("id"))); + } + + return result; + } + + //--------------------------------------------------------------------------- + + public static Element toJeevesException(OaiPmhException e) + { + String msg = e.getMessage(); + String cls = e.getClass().getSimpleName(); + String id = e.getCode(); + Element res = e.getResponse(); + + Element error = new Element(Jeeves.Elem.ERROR) + .addContent(new Element("message").setText(msg)) + .addContent(new Element("class") .setText(cls)); + + error.setAttribute("id", id); + + if (res != null) + { + Element elObj = new Element("object"); + elObj.addContent(res.detach()); + + error.addContent(elObj); + } + + return error; + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + private static ServiceConfig dummyConfig = new ServiceConfig(); +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhDispatcher.java =================================================================== --- trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhDispatcher.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhDispatcher.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,163 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.oaipmh; + +import java.util.HashMap; +import java.util.Map; +import jeeves.constants.Jeeves; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Util; +import jeeves.utils.Xml; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.oaipmh.services.GetRecord; +import org.fao.geonet.kernel.oaipmh.services.Identify; +import org.fao.geonet.kernel.oaipmh.services.ListIdentifiers; +import org.fao.geonet.kernel.oaipmh.services.ListMetadataFormats; +import org.fao.geonet.kernel.oaipmh.services.ListRecords; +import org.fao.geonet.kernel.oaipmh.services.ListSets; +import org.fao.geonet.kernel.setting.SettingInfo; +import org.fao.oaipmh.exceptions.BadArgumentException; +import org.fao.oaipmh.exceptions.OaiPmhException; +import org.fao.oaipmh.requests.AbstractRequest; +import org.fao.oaipmh.responses.AbstractResponse; +import org.fao.oaipmh.server.OaiPmhFactory; +import org.fao.oaipmh.util.Lib; +import org.jdom.Element; + +//============================================================================= + +public class OaiPmhDispatcher +{ + //--------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //--------------------------------------------------------------------------- + + public OaiPmhDispatcher() + { + register(new GetRecord()); + register(new Identify()); + register(new ListIdentifiers()); + register(new ListMetadataFormats()); + register(new ListRecords()); + register(new ListSets()); + } + + //--------------------------------------------------------------------------- + + private void register(OaiPmhService s) + { + hmServices.put(s.getVerb(), s); + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public Element dispatch(Element request, ServiceContext context) + { + Element response = dispatchI(request, context); + validateResponse(context, response); + + return response; + } + + //--------------------------------------------------------------------------- + //--- + //--- Private method + //--- + //--------------------------------------------------------------------------- + + private Element dispatchI(Element request, ServiceContext context) + { + String url = null; + + Map<String, String> params = null; + + SettingInfo si = new SettingInfo(context); + + try + { + url = si.getSiteUrl() + context.getBaseUrl() +"/"+ Jeeves.Prefix.SERVICE +"/en/"+ context.getService(); + params = OaiPmhFactory.extractParams(request); + + AbstractRequest req = OaiPmhFactory.parse(params); + OaiPmhService srv = hmServices.get(req.getVerb()); + AbstractResponse res = srv.execute(req, context); + + Element response = res.toXml(); + + return Lib.createOaiRoot(url, params, response); + } + + catch(OaiPmhException e) + { + return OaiPmhException.marshal(e, url, params); + } + + catch(Exception e) + { + context.info("Exception stack trace : \n"+ Util.getStackTrace(e)); + + //--- we should use another exception type but we don't have a specific + //--- type to handle internal errors + + BadArgumentException ex = new BadArgumentException("Internal error : "+ e.getMessage()); + + return OaiPmhException.marshal(ex, url, params); + } + } + + //--------------------------------------------------------------------------- + + private void validateResponse(ServiceContext context, Element response) + { + String schema = context.getAppPath() + Geonet.SchemaPath.OAI_PMH; + + context.debug("Validating against : "+ schema); + + try + { + Xml.validate(schema, response); + } + catch (Exception e) + { + context.warning("OAI-PMH response does not validate : "+e.getMessage()); + } + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + + private HashMap<String, OaiPmhService> hmServices = new HashMap<String, OaiPmhService>(); +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhService.java =================================================================== --- trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhService.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/oaipmh/OaiPmhService.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,43 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.oaipmh; + +import jeeves.server.context.ServiceContext; +import org.fao.oaipmh.exceptions.OaiPmhException; +import org.fao.oaipmh.requests.AbstractRequest; +import org.fao.oaipmh.responses.AbstractResponse; + +//============================================================================= + +public interface OaiPmhService +{ + public String getVerb(); + + /** Executes the service on given input request */ + public AbstractResponse execute(AbstractRequest request, ServiceContext context) + throws OaiPmhException, Exception; +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kernel/oaipmh/services/GetRecord.java =================================================================== --- trunk/src/org/fao/geonet/kernel/oaipmh/services/GetRecord.java (rev 0) +++ trunk/src/org/fao/geonet/kernel/oaipmh/services/GetRecord.java 2007-10-06 15:35:21 UTC (rev 886) @@ -0,0 +1,145 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.geonet.kernel.oaipmh.services; + +import java.util.List; +import jeeves.resources.dbms.Dbms; +import jeeves.server.context.ServiceContext; +import jeeves.utils.Xml; +import org.fao.geonet.GeonetContext; +import org.fao.geonet.constants.Geonet; +import org.fao.geonet.kernel.DataManager; +import org.fao.geonet.kernel.oaipmh.Lib; +import org.fao.geonet.kernel.oaipmh.OaiPmhService; +import org.fao.geonet.util.ISODate; +import org.fao.oaipmh.OaiPmh; +import org.fao.oaipmh.exceptions.CannotDisseminateFormatException; +import org.fao.oaipmh.exceptions.IdDoesNotExistException; +import org.fao.oaipmh.requests.AbstractRequest; +import org.fao.oaipmh.requests.GetRecordRequest; +import org.fao.oaipmh.responses.AbstractResponse; +import org.fao.oaipmh.responses.GetRecordResponse; +import org.fao.oaipmh.responses.Header; +import org.fao.oaipmh.responses.Record; +import org.jdom.Element; + +//============================================================================= + +public class GetRecord implements OaiPmhService +{ + public String getVerb() { return GetRecordRequest.VERB; } + + //--------------------------------------------------------------------------- + //--- + //--- Service + //--- + //--------------------------------------------------------------------------- + + public AbstractResponse execute(AbstractRequest request, ServiceContext context) throws Exception + { + GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); + DataManager dm = gc.getDataManager(); + + GetRecordRequest req = (GetRecordRequest) request; + GetRecordResponse res = new GetRecordResponse(); + + String uuid = req.getIdentifier(); + String prefix = req.getMetadataPrefix(); + + res.setRecord(buildRecord(context, uuid, prefix)); + + return res; + } + + //--------------------------------------------------------------------------- + + private Record buildRecord(ServiceContext context, String uuid, String prefix) throws Exception + { + Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); + + String query = "SELECT id, schemaId, changeDate, data FROM Metadata WHERE uuid=?"; + + List list = dbms.select(query, uuid).getChildren(); + + if (list.size() == 0) + throw new IdDoesNotExistException(uuid); + + Element rec = (Element) list.get(0); + + String id = rec.getChildText("id"); + String schema = rec.getChildText("schemaid"); + String changeDate = rec.getChildText("changedate"); + String data = rec.getChildText("data"); + + Element md = Xml.loadString(data, false); + + //--- try to disseminate format + + if (prefix.equals(schema)) + { + String schemaUrl = Lib.getSchemaUrl(context, "xml/schemas/" + schema + "/schema.xsd"); + String schemaLoc = md.getNamespace().getURI() +" "+ schemaUrl; + md.setAttribute("schemaLocation", schemaLoc, OaiPmh.Namespaces.XSI); + } + else + { + if (!prefix.equals("oai_dc")) + throw new CannotDisseminateFormatException("Unknown prefix : "+ prefix); + + md = Lib.toOaiDC(schema, md, uuid, changeDate, context.getAppPath()); + } + + //--- build header and set some infos + + Header h = new Header(); + + h.setIdentifier(uuid); + h.setDateStamp(new ISODate(changeDate)); + + //--- find and add categories (here called sets) + + query = "SELECT name FROM Categories, MetadataCateg WHERE id=categoryId AND metadataId=?"; + + list = dbms.select(query, new Integer(id)).getChildren(); + + for (Object o : list) + { + rec = (Element) o; + + h.addSet(rec.getChildText("name")); + } + + //--- build and return record + + Record r = new Record(); + + r.setHeader(h); + r.setMetadata(md); + + return r; + } +} + +//============================================================================= + Added: trunk/src/org/fao/geonet/kerne... [truncated message content] |
From: <aca...@us...> - 2007-10-06 16:01:00
|
Revision: 890 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=890&view=rev Author: acarboni Date: 2007-10-06 09:01:03 -0700 (Sat, 06 Oct 2007) Log Message: ----------- Fixed migration bug Modified Paths: -------------- trunk/gast/data/gui.xml trunk/gast/log/log4j.cfg trunk/src/org/fao/gast/gui/panels/migration/oldinst/GNSource.java Added Paths: ----------- trunk/src/org/fao/gast/gui/panels/migration/oldinst/OldConfigLib.java Modified: trunk/gast/data/gui.xml =================================================================== --- trunk/gast/data/gui.xml 2007-10-06 15:55:58 UTC (rev 889) +++ trunk/gast/data/gui.xml 2007-10-06 16:01:03 UTC (rev 890) @@ -305,16 +305,14 @@ <title>Migrate an old GeoNetwork</title> <class>migration.oldinst.MainPanel</class> <description> - This panel allows you to migrate metadata from an old GeoNetwork + This panel allows you to migrate metadata from an old GeoNetwork 2.0.x installation. This procedure migrates the database content. After this stage, you will probably need to setup some parameters into the config.xml file (like dataDir). Other parameters (like proxy settings) must be changed using the web interface. Harvested - metadata are not migrated. When migrating both old and new nodes MUST not - be started. Once the directory selected, GAST will look for an Old installation - dir as SELECTED_DIR/web/geonetwork/WEB-INF/config.xml (It could be different - according to installation made of 2.0.3, web/geonetwork could not exist or - be slightly different according to servlet name. If needed, update directory name). + metadata are not migrated. When migrating, both old and new nodes MUST NOT + be started. If you use Tomcat and you have used only the geonetwork's + 'web' folder you have to select the GeoNetwork's web app folder inside Tomcat. </description> <button> Modified: trunk/gast/log/log4j.cfg =================================================================== --- trunk/gast/log/log4j.cfg 2007-10-06 15:55:58 UTC (rev 889) +++ trunk/gast/log/log4j.cfg 2007-10-06 16:01:03 UTC (rev 890) @@ -3,7 +3,7 @@ ### GAST SETTINGS ######################################################## -log4j.logger.gast = DEBUG, gast +log4j.logger.gast = DEBUG, gast, console ### GAST APPENDER ############################################################ @@ -12,3 +12,9 @@ log4j.appender.gast.file = <do not change. changed by gast> log4j.appender.gast.layout = org.apache.log4j.PatternLayout log4j.appender.gast.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n + +### CONSOLE SETTINGS ########################################################### + +log4j.appender.console = org.apache.log4j.ConsoleAppender +log4j.appender.console.layout = org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n Modified: trunk/src/org/fao/gast/gui/panels/migration/oldinst/GNSource.java =================================================================== --- trunk/src/org/fao/gast/gui/panels/migration/oldinst/GNSource.java 2007-10-06 15:55:58 UTC (rev 889) +++ trunk/src/org/fao/gast/gui/panels/migration/oldinst/GNSource.java 2007-10-06 16:01:03 UTC (rev 890) @@ -24,8 +24,6 @@ package org.fao.gast.gui.panels.migration.oldinst; import java.io.IOException; -import org.fao.gast.lib.ConfigLib; -import org.fao.gast.lib.ProfileLib; import org.jdom.JDOMException; //============================================================================== @@ -40,10 +38,7 @@ public GNSource(String oldAppPath) throws JDOMException, IOException { - appPath = oldAppPath; - - config = new ConfigLib (oldAppPath); - profiles = new ProfileLib(oldAppPath); + config = new OldConfigLib(oldAppPath); } //--------------------------------------------------------------------------- @@ -65,9 +60,7 @@ //--- //-------------------------------------------------------------------------- - private String appPath; - public ConfigLib config; - public ProfileLib profiles; + public OldConfigLib config; } //============================================================================== Added: trunk/src/org/fao/gast/gui/panels/migration/oldinst/OldConfigLib.java =================================================================== --- trunk/src/org/fao/gast/gui/panels/migration/oldinst/OldConfigLib.java (rev 0) +++ trunk/src/org/fao/gast/gui/panels/migration/oldinst/OldConfigLib.java 2007-10-06 16:01:03 UTC (rev 890) @@ -0,0 +1,137 @@ +//============================================================================= +//=== 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: geo...@os... +//============================================================================== + +package org.fao.gast.gui.panels.migration.oldinst; + +import java.io.File; +import java.io.IOException; +import jeeves.constants.ConfigFile; +import org.fao.gast.lib.Lib; +import org.fao.gast.lib.Resource; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; + +//============================================================================= + +public class OldConfigLib +{ + //--------------------------------------------------------------------------- + //--- + //--- Constructor + //--- + //--------------------------------------------------------------------------- + + public OldConfigLib(String appPath) throws JDOMException, IOException + { + webPath = appPath +"/web/"; + + String cfgFile = "/web/WEB-INF/config.xml"; + + if (!new File(appPath + cfgFile).exists()) + { + webPath = appPath +"/"; + cfgFile = "/WEB-INF/config.xml"; + } + + config = Lib.xml.load(appPath + cfgFile); + dbmsElem = retrieveDbms(config); + appHandElem = config.getRootElement().getChild(ConfigFile.Child.APP_HANDLER); + } + + //--------------------------------------------------------------------------- + //--- + //--- API methods + //--- + //--------------------------------------------------------------------------- + + public String getHandlerProp(String name) + { + return findInHandler(name); + } + + //--------------------------------------------------------------------------- + + public Resource createResource() throws Exception + { + return new Resource(webPath, dbmsElem); + } + + //--------------------------------------------------------------------------- + //--- + //--- Private methods + //--- + //--------------------------------------------------------------------------- + + private Element retrieveDbms(Document config) + { + Element resources = config.getRootElement().getChild(ConfigFile.Child.RESOURCES); + + for (Object res : resources.getChildren(ConfigFile.Resources.Child.RESOURCE)) + { + Element resource = (Element) res; + String enabled = resource.getAttributeValue("enabled"); + + if ("true".equals(enabled)) + return resource; + } + + //--- we should not arrive here + + return null; + } + + //--------------------------------------------------------------------------- + + private String findInHandler(String paramName) + { + for (Object o : appHandElem.getChildren("param")) + { + Element param = (Element) o; + + String name = param.getAttributeValue("name"); + String value= param.getAttributeValue("value"); + + if (paramName.equals(name)) + return value; + } + + return null; + } + + //--------------------------------------------------------------------------- + //--- + //--- Variables + //--- + //--------------------------------------------------------------------------- + +// private String appPath; + private String webPath; + private Document config; + private Element dbmsElem; + private Element appHandElem; +} + +//============================================================================= + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |