=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm 2010-03-16 07:56:31 +0000 @@ -0,0 +1,2 @@ + +$encoder.xmlEncode( $message ) === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java 2010-03-16 07:56:31 +0000 @@ -0,0 +1,161 @@ +package org.hisp.dhis.reporting.document.action; + +/* + * Copyright (c) 2004-2007, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.document.Document; +import org.hisp.dhis.document.DocumentService; +import org.hisp.dhis.external.location.LocationManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + * @version $Id$ + */ +public class UpdateDocumentAction + implements Action +{ + private static final Log log = LogFactory.getLog( UpdateDocumentAction.class ); + + private static final String HTTP_PREFIX = "http://"; + + private static final String HTTPS_PREFIX = "https://"; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DocumentService documentService; + + public void setDocumentService( DocumentService documentService ) + { + this.documentService = documentService; + } + + private LocationManager locationManager; + + public void setLocationManager( LocationManager locationManager ) + { + this.locationManager = locationManager; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String url; + + public void setUrl( String url ) + { + this.url = url; + } + + private Boolean external; + + public void setExternal( Boolean external ) + { + this.external = external; + } + + private File file; + + public void setUpload( File file ) + { + this.file = file; + } + + private String fileName; + + public void setUploadFileName( String fileName ) + { + this.fileName = fileName; + } + + private String contentType; + + public void setUploadContentType( String contentType ) + { + this.contentType = contentType; + } + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + Document document = documentService.getDocument( id ); + document.setName( name ); + document.setExternal( external ); + + if ( !external && file != null ) + { + log.info( "Uploading file: '" + fileName + "', content-type: '" + contentType + "'" ); + + File destination = locationManager.getFileForWriting( fileName, DocumentService.DIR ); + boolean fileMoved = file.renameTo( destination ); + + if ( !fileMoved ) + { + throw new RuntimeException( "File was not uploaded" ); + } + document.setUrl( fileName ); + } + else if(external) + { + if ( !(url.startsWith( HTTP_PREFIX ) || url.startsWith( HTTPS_PREFIX )) ) + { + url = HTTP_PREFIX + url; + } + document.setUrl( url ); + } + + documentService.saveDocument( document ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java 2010-03-16 07:56:31 +0000 @@ -0,0 +1,127 @@ +package org.hisp.dhis.reporting.document.action; + +/* + * Copyright (c) 2004-2007, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.document.Document; +import org.hisp.dhis.document.DocumentService; +import org.hisp.dhis.i18n.I18n; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + * @version $Id$ + */ +public class ValidateUpdateDocumentAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DocumentService documentService; + + public void setDocumentService( DocumentService documentService ) + { + this.documentService = documentService; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + if ( name == null ) + { + message = i18n.getString( "specify_name" ); + + return INPUT; + } + else + { + name = name.trim(); + + if ( name.length() == 0 ) + { + message = i18n.getString( "specify_name" ); + + return INPUT; + } + + Document match = documentService.getDocumentByName( name ); + + if ( match != null && (id == null || match.getId() != id) ) + { + message = i18n.getString( "name_in_use" ); + + return INPUT; + } + } + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-03-10 15:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-03-16 07:56:31 +0000 @@ -18,6 +18,15 @@ ref="org.hisp.dhis.external.location.LocationManager"/> + + + + + === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-03-10 15:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-03-16 07:56:31 +0000 @@ -22,6 +22,12 @@ F_DOCUMENT_ADD + + displayViewDocumentForm.action + + F_DOCUMENT_UPDATE + + /dhis-web-commons/ajax/jsonResponseSuccess.vm F_DOCUMENT_DELETE @@ -41,6 +47,14 @@ javascript/document.js + + /main.vm + /dhis-web-reporting/updateDocumentForm.vm + /dhis-web-reporting/menu.vm + javascript/document.js + F_DOCUMENT_UPDATE + + /dhis-web-reporting/responseSuccess.vm /dhis-web-reporting/responseInput.vm === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2010-02-17 13:38:15 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2010-03-16 07:56:31 +0000 @@ -2,7 +2,17 @@ function saveDocument() { var url = "validateDocument.action?name=" + getFieldValue( "name" ); - + + var request = new Request(); + request.setResponseTypeXML( 'message' ); + request.setCallbackSuccess( saveDocumentReceived ); + request.send( url ); +} + +function updateDocument() +{ + var url = "validateDocument.action?name=" + getFieldValue( "name" ) + "&id=" + getFieldValue('id'); + var request = new Request(); request.setResponseTypeXML( 'message' ); request.setCallbackSuccess( saveDocumentReceived ); === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm 2010-03-16 07:56:31 +0000 @@ -0,0 +1,61 @@ + +

$i18n.getString( 'update_new_static_report' )

+ +
+ + + + + + + + + + + + + +
$i18n.getString( "details" )
+ +
+ +
+ + + + + +
+
+ + + + + + + + + + + +
+ +
+ +
+ +$!message + === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm 2010-02-15 18:55:09 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm 2010-03-16 07:56:31 +0000 @@ -25,8 +25,9 @@ #foreach ( $document in $documents ) $encoder.htmlEncode( $document.name ) - - #if ( $document.external ) + + $i18n.getString( + #if ( $document.external ) #else