Project

General

Profile

« Previous | Next » 

Revision 3993

Added by berkley over 16 years ago

made it so that the error and success messages from a multipart upload can be transformed using xslt. also added upload functionality to the sms skin

View differences:

lib/web.xml.tomcat5
202 202
        <load-on-startup>3</load-on-startup>
203 203
    </servlet>
204 204

  
205
    <!--
206 205
    <servlet>
207 206
      <servlet-name>HarvesterServlet</servlet-name>
208 207
      <servlet-class>edu.ucsb.nceas.metacat.harvesterClient.HarvesterServlet</servlet-class>
......
216 215
      </init-param>
217 216
      <load-on-startup>3</load-on-startup>
218 217
    </servlet>
219
    -->
220
    <servlet>
218
    
219
<servlet>
221 220
      <servlet-name>AxisServlet</servlet-name>
222 221
      <display-name>Apache-Axis Servlet</display-name>
223 222
      <servlet-class>
lib/harvester/runHarvestListEditor.sh
2 2
METACAT_LIB=$METACAT_HOME/lib
3 3
LIB_JARS=$METACAT_LIB/xercesImpl.jar
4 4
export CLASSPATH=$METACAT_CLASSES:$LIB_JARS
5
cd $METACAT_LIB/harvester
6
java edu.ucsb.nceas.metacat.harvesterClient.HarvestListEditor
5
java -cp $METACAT_CLASSES:$LIB_JARS edu.ucsb.nceas.metacat.harvesterClient.HarvestListEditor
lib/metacat.properties
236 236

  
237 237
delay=0
238 238

  
239
harvesterAdministrator=name@institution.edu
239
harvesterAdministrator=berkley@nceas.ucsb.edu
240 240

  
241 241
logPeriod=90
242 242

  
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
2900 2900
        if (action.equals("upload")) {
2901 2901
            if (username != null && !username.equals("public")) {
2902 2902
                handleUploadAction(request, out, params, fileList, username,
2903
                        groupnames);
2903
                        groupnames, response);
2904 2904
            } else {
2905 2905
                
2906 2906
                out.println("<?xml version=\"1.0\"?>");
......
2929 2929
     */
2930 2930
    private void handleUploadAction(HttpServletRequest request,
2931 2931
            PrintWriter out, Hashtable params, Hashtable fileList,
2932
            String username, String[] groupnames) {
2932
            String username, String[] groupnames, HttpServletResponse response) {
2933 2933
        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
2934 2934
        //PrintWriter out = null;
2935 2935
        //Connection conn = null;
2936 2936
        String action = null;
2937 2937
        String docid = null;
2938
        String qformat = null;
2939
        String output = "";
2938 2940
        
2939 2941
        /*
2940 2942
         * response.setContentType("text/xml"); try { out =
......
2947 2949
            docid = (String) params.get("docid");
2948 2950
        }
2949 2951
        
2952
        if(params.containsKey("qformat")) {
2953
            qformat = (String)params.get("qformat");
2954
        }
2955
        
2950 2956
        // Make sure we have a docid and datafile
2951 2957
        if (docid != null && fileList.containsKey("datafile")) {
2952 2958
            logMetacat.info("Uploading data docid: " + docid);
......
3025 3031
                        
3026 3032
                        // set content type and other response header fields
3027 3033
                        // first
3028
                        out.println("<?xml version=\"1.0\"?>");
3029
                        out.println("<success>");
3030
                        out.println("<docid>" + docid + "</docid>");
3031
                        out.println("<size>" + size + "</size>");
3032
                        out.println("</success>");
3034
                        output += "<?xml version=\"1.0\"?>";
3035
                        output += "<success>";
3036
                        output += "<docid>" + docid + "</docid>";
3037
                        output += "<size>" + size + "</size>";
3038
                        output += "</success>";
3033 3039
                    }
3034 3040
                    
3035 3041
                } catch (Exception e) {
3036 3042
                    
3037
                    out.println("<?xml version=\"1.0\"?>");
3038
                    out.println("<error>");
3039
                    out.println(e.getMessage());
3040
                    out.println("</error>");
3043
                    output += "<?xml version=\"1.0\"?>";
3044
                    output += "<error>";
3045
                    output += e.getMessage();
3046
                    output += "</error>";
3041 3047
                }
3042 3048
            } else {
3043 3049
                // the field did not contain a file
3044
                out.println("<?xml version=\"1.0\"?>");
3045
                out.println("<error>");
3046
                out.println("The uploaded data did not contain a valid file.");
3047
                out.println("</error>");
3050
                output += "<?xml version=\"1.0\"?>";
3051
                output += "<error>";
3052
                output += "The uploaded data did not contain a valid file.";
3053
                output += "</error>";
3048 3054
            }
3049 3055
        } else {
3050 3056
            // Error bcse docid missing or file missing
3051
            out.println("<?xml version=\"1.0\"?>");
3052
            out.println("<error>");
3053
            out.println("The uploaded data did not contain a valid docid "
3054
                    + "or valid file.");
3055
            out.println("</error>");
3057
            output += "<?xml version=\"1.0\"?>";
3058
            output += "<error>";
3059
            output += "The uploaded data did not contain a valid docid "
3060
                    + "or valid file.";
3061
            output += "</error>";
3056 3062
        }
3063
        
3064
        if (qformat == null || qformat.equals("xml")) {
3065
            response.setContentType("text/xml");
3066
            out.println(output);
3067
        } else {
3068
            try {
3069
                DBTransform trans = new DBTransform();
3070
                response.setContentType("text/html");
3071
                trans.transformXMLDocument(output,
3072
                        "success", "-//W3C//HTML//EN", qformat,
3073
                        out, null);
3074
            } catch (Exception e) {
3075
                
3076
                logMetacat.error(
3077
                        "Error in MetaCatServlet.handleLoginAction: "
3078
                        + e.getMessage());
3079
            }
3080
        }
3057 3081
    }
3058 3082
    
3059 3083
    /*
build.properties
1 1
# Ant build properties files for the metacat build
2 2

  
3 3
# Tomcat Properties
4
tomcat=/usr/local/devtools/jakarta-tomcat
5
deploy.dir=/var/www/org.ecoinformatics.knb
4
tomcat=/usr/local/devtools/tomcat
5
deploy.dir=/usr/local/devtools/tomcat/webapps
6 6
#deploy.dir=${tomcat}/webapps
7 7

  
8 8
# Tomcat version - tomcat4 or tomcat5
9 9
tomcatversion=tomcat5
10 10

  
11 11
# Servlet properties
12
metacat.context=knb
12
metacat.context=sms
13 13
authority.context=authority
14 14

  
15 15
# Server Properties
16
config.hostname=knb.ecoinformatics.org
16
config.hostname=linus.nceas.ucsb.edu
17 17
config.port=80
18 18
config.port.https=443
19 19
# Server is the domain name for replication purpose, which should be with https port
......
44 44

  
45 45
# Metacat database user and password and location of file stores
46 46
user=metacat
47
password=yourPasswordHere
47
password=dta4all
48 48
datafilepath=/var/metacat/data
49 49
inlinedatafilepath=/var/metacat/inline-data
50 50

  
......
52 52
cvsroot=:ext:${env.USER}@cvs.ecoinformatics.org:/cvs
53 53

  
54 54
# Configure the installed skins, and select the default
55
default-style=default
55
default-style=sms
56 56

  
57 57
# this is the url to the web context root for the knb site. 
58 58
# It is used for the qformat=knb skin only
......
120 120

  
121 121
# The metacat current dir's abolute value. If you set install.ecogrid=false, this variable
122 122
#  do NOT need to be configured
123
metacat.dir=/home/tao/project/metacat
123
metacat.dir=/home/berkley/project/metacat
124 124

  
build.xml
209 209
      <property name="eml-version"         value="2.0.0beta6" />
210 210
      <property name="eml-tag"             value="EML_2_0_0_BETA_6_FOR_METACAT" />
211 211
      <property name="eml2_0_0-tag"        value="RELEASE_EML_2_0_0_UPDATE_1" />
212
      <property name="eml2_0_1-schema-tag" value="RELEASE_EML_2_0_1" />
212
      <property name="eml2_0_1-schema-tag" value="RELEASE_EML_2_0_1_UPDATE_6" />
213 213
      <property name="eml2_0_1-style-tag"  value="RELEASE_EML_2_0_1_UPDATE_6" />
214 214
      <property name="eml2_0_0namespace"   value="eml://ecoinformatics.org/eml-2.0.0" />
215 215
      <property name="eml2_0_1namespace"   value="eml://ecoinformatics.org/eml-2.0.1" />
......
433 433
       <javac srcdir="${build.src}"
434 434
              destdir="${build.dest}"
435 435
              debug="${debug}"
436
              excludes="**/*.sql **/stringclient/** **/client/*.java **/harvesterClient/*.java">
436
              excludes="**/*.sql **/stringclient/** **/client/*.java">
437 437
        <classpath>
438 438
          <path refid="compile.classpath"/>
439 439
        </classpath>
......
998 998
   <target name="install-skin" depends="init"
999 999
            description="Install a Skin">
1000 1000

  
1001
      <input message="Please enter name of the skin"
1002
             addproperty="skin-name"/>
1001
      <!--<input message="Please enter name of the skin"
1002
             addproperty="skin-name"/>-->
1003
      <property name="skin-name" value="sms"/>
1003 1004

  
1004 1005
      <mkdir dir="${installdir}/style/skins/${skin-name}" />
1005 1006
      <copy todir="${installdir}/style/skins/${skin-name}" filtering="yes">
......
1014 1015
     <copy todir="${installdir}/style/skins/${skin-name}" filtering="no">
1015 1016
       <fileset dir="lib/style/skins/${skin-name}">
1016 1017
           <include name="**/*.png"/>
1017
           <include name="**/*.gif"/>
1018 1018
           <include name="**/*.jpg"/>
1019 1019
           <exclude name="**/CVS*"/>
1020 1020
           <exclude name="**/.#*"/>

Also available in: Unified diff