From: <jos...@us...> - 2010-04-15 09:54:00
|
Revision: 5965 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=5965&view=rev Author: josegar74 Date: 2010-04-15 09:53:53 +0000 (Thu, 15 Apr 2010) Log Message: ----------- #207: Metadata insert GUI fixes Modified Paths: -------------- branches/2.4.x/src/org/fao/geonet/kernel/mef/Importer.java branches/2.4.x/src/org/fao/geonet/services/mef/Import.java branches/2.4.x/web/geonetwork/WEB-INF/config.xml branches/2.4.x/web/geonetwork/WEB-INF/user-profiles.xml branches/2.4.x/web/geonetwork/loc/ar/xml/strings.xml branches/2.4.x/web/geonetwork/loc/cn/xml/strings.xml branches/2.4.x/web/geonetwork/loc/de/xml/strings.xml branches/2.4.x/web/geonetwork/loc/en/xml/strings.xml branches/2.4.x/web/geonetwork/loc/es/xml/strings.xml branches/2.4.x/web/geonetwork/loc/fr/xml/strings.xml branches/2.4.x/web/geonetwork/loc/nl/xml/strings.xml branches/2.4.x/web/geonetwork/loc/ru/xml/strings.xml branches/2.4.x/web/geonetwork/xsl/metadata-insert-form.xsl Modified: branches/2.4.x/src/org/fao/geonet/kernel/mef/Importer.java =================================================================== --- branches/2.4.x/src/org/fao/geonet/kernel/mef/Importer.java 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/src/org/fao/geonet/kernel/mef/Importer.java 2010-04-15 09:53:53 UTC (rev 5965) @@ -43,6 +43,7 @@ import org.fao.geonet.constants.Params; import org.fao.geonet.kernel.DataManager; import org.fao.geonet.lib.Lib; +import org.fao.geonet.services.metadata.ImportFromDir; import org.fao.geonet.util.ISODate; import org.fao.oaipmh.exceptions.BadArgumentException; import org.jdom.Element; @@ -116,6 +117,8 @@ .getSiteId()); isTemplate = Util.getParam(params, Params.TEMPLATE, "n"); + boolean validate = Util.getParam(params, Params.VALIDATE, "off").equals("on"); + categs = new Element("categories"); categs.addContent((new Element("category")).setAttribute( "name", Util.getParam(params, Params.CATEGORY))); @@ -136,7 +139,12 @@ md[0] = Xml.transform(md[0],stylePath+"/"+style); schema = dm.autodetectSchema(md[0]); - + + if (schema == null) + throw new Exception("Unknown schema format"); + + if (validate) ImportFromDir.validateIt(schema, md[0], context); + // Get the Metadata uuid if (isTemplate.equals("n")) uuid = dm.extractUUID(schema, md[0]); @@ -162,7 +170,7 @@ } if (schema == null) - throw new Exception("Unknown schema format : " + schema); + throw new Exception("Unknown schema format"); String uuidAction = Util.getParam(params, Params.UUID_ACTION, Params.NOTHING); Modified: branches/2.4.x/src/org/fao/geonet/services/mef/Import.java =================================================================== --- branches/2.4.x/src/org/fao/geonet/services/mef/Import.java 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/src/org/fao/geonet/services/mef/Import.java 2010-04-15 09:53:53 UTC (rev 5965) @@ -24,12 +24,15 @@ package org.fao.geonet.services.mef; import java.io.File; + +import jeeves.constants.Jeeves; import jeeves.interfaces.Service; import jeeves.server.ServiceConfig; import jeeves.server.context.ServiceContext; import jeeves.utils.Util; import org.fao.geonet.constants.Geonet; +import org.fao.geonet.constants.Params; import org.fao.geonet.kernel.mef.MEFLib; import org.jdom.Element; @@ -61,8 +64,18 @@ //--- return success with the metadata id - Element result = new Element("ok"); - result.setText(id +""); + String fileType = Util.getParam(params, Params.FILE_TYPE); + + Element result = null; + if (context.getService().equals("mef.import")) { + result = new Element("ok"); + result.setText(id +""); + } else { + // Response for mef.import.ui (used in UI for File import UI) + // Unified with response from mef.insert.paste (used when sending the content metadata in same UI + result = new Element(Jeeves.Elem.RESPONSE); + result.addContent(new Element(Params.ID).setText(id +"")); + } return result; } Modified: branches/2.4.x/web/geonetwork/WEB-INF/config.xml =================================================================== --- branches/2.4.x/web/geonetwork/WEB-INF/config.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/WEB-INF/config.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -870,6 +870,18 @@ <error sheet="xml-error.xsl" contentType="application/xml; charset=UTF-8" /> </service> + <!-- Used in Import UI from administration --> + <service name="mef.import.ui"> + <class name=".services.mef.Import" /> + + <output sheet="metadata-insert-results.xsl"/> + + <error sheet="error.xsl"> + <xml name="error" file="xml/validation-error.xml" /> + <xml name="validation" file="xml/metadata-validate.xml" /> + </error> + </service> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <service name="mef.export"> Modified: branches/2.4.x/web/geonetwork/WEB-INF/user-profiles.xml =================================================================== --- branches/2.4.x/web/geonetwork/WEB-INF/user-profiles.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/WEB-INF/user-profiles.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -177,6 +177,7 @@ <!-- MEF facilities --> <allow service="mef.import"/> + <allow service="mef.import.ui"/> <!-- Relation services --> <allow service="xml.relation.insert"/> Modified: branches/2.4.x/web/geonetwork/loc/ar/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/ar/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/ar/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -643,5 +643,6 @@ <upload>Upload thesaurus</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/cn/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/cn/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/cn/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -634,5 +634,6 @@ <upload>Upload thesaurus</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/de/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/de/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/de/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -635,5 +635,6 @@ <upload>Thesaurus hochladen</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/en/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/en/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/en/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -636,5 +636,6 @@ <upload>Upload thesaurus</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/es/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/es/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/es/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -636,5 +636,6 @@ <upload>Subir tesauro</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/fr/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/fr/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/fr/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -650,5 +650,6 @@ <upload>Télécharger un thésaurus</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/nl/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/nl/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/nl/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -657,5 +657,6 @@ <upload>Uploaden thesaurus</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/loc/ru/xml/strings.xml =================================================================== --- branches/2.4.x/web/geonetwork/loc/ru/xml/strings.xml 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/loc/ru/xml/strings.xml 2010-04-15 09:53:53 UTC (rev 5965) @@ -638,5 +638,6 @@ <upload>Выгрузить тезаурус</upload> </thesaurus> + <selectMetadataFileAlert>You must select a metadata file to insert</selectMetadataFileAlert> <showMoreSearchFields>Show/Hide more search fields</showMoreSearchFields> </strings> Modified: branches/2.4.x/web/geonetwork/xsl/metadata-insert-form.xsl =================================================================== --- branches/2.4.x/web/geonetwork/xsl/metadata-insert-form.xsl 2010-04-15 09:27:11 UTC (rev 5964) +++ branches/2.4.x/web/geonetwork/xsl/metadata-insert-form.xsl 2010-04-15 09:53:53 UTC (rev 5965) @@ -66,8 +66,8 @@ $('gn.fileType').style.display=''; $('gn.uuidAction').style.display=''; document.xmlinsert.enctype="multipart/form-data"; - document.xmlinsert.action=Env.locService+"/mef.import"; - document.xmlinsert.target='upFrame'; + document.xmlinsert.action=Env.locService+"/mef.import.ui"; + document.xmlinsert.target='_self'; } } @@ -153,6 +153,17 @@ } } + function submitInsertForm() { + if (getModeValue() == '1') { + if ($('mefFileContent').value == '') { + alert('<xsl:value-of select="/root/gui/strings/selectMetadataFileAlert"/>'); + return false; + } + } + + goSubmit('xmlinsert'); + } + </script> </xsl:template> @@ -213,7 +224,7 @@ <textarea class="content" name="data" cols="80" rows="20"/> </span> <span id="gn.fileUp" style="display:none"> - <input type="file" accept="*.xml, *.zip, *.mef" class="content" size="60" name="mefFile" value=""/> + <input type="file" accept="*.xml, *.zip, *.mef" class="content" size="60" name="mefFile" id="mefFileContent" value=""/> </span> </td> </tr> @@ -254,7 +265,7 @@ <xsl:with-param name="buttons"> <button class="content" onclick="goBack()" id="back"><xsl:value-of select="/root/gui/strings/back"/></button>   - <button class="content" onclick="goSubmit('xmlinsert')" id="btInsert"><xsl:value-of select="/root/gui/strings/insert"/></button> + <button class="content" onclick="return submitInsertForm();" id="btInsert"><xsl:value-of select="/root/gui/strings/insert"/></button> </xsl:with-param> </xsl:call-template> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |