Project

General

Profile

« Previous | Next » 

Revision 355

Added by berkley almost 24 years ago

Added decodeMouseAction(Hashtable) to decode the mouse click action outside of handleGetOrPost to allow for easy modification of images in a different application.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
156 156
   */
157 157
  private void handleGetOrPost(HttpServletRequest request, 
158 158
    HttpServletResponse response) 
159
    throws ServletException, IOException {
159
    throws ServletException, IOException 
160
 {
160 161

  
161 162
    if ( util == null ) {
162 163
        util = new MetaCatUtil(); 
......
197 198
      //out.println(name + " => " + value[0]);
198 199
      params.put(name,value);
199 200
    }
200

  
201
    // Determine what type of request the user made
202
    // if the action parameter is set, use it as a default
203
    // but if the ypos param is set, calculate the action needed
204
    String action = ((String[])params.get("action"))[0];
205
    long ypos = 0;
206
    try {
207
      ypos = (new Long(((String[])params.get("ypos"))[0]).longValue());
208
      //out.println("<P>YPOS IS " + ypos);
209
      if (ypos <= 13) {
210
        action = "getdocument";
211
      } else if (ypos > 13 && ypos <= 27) {
212
        action = "validate";
213
      } else if (ypos > 27) {
214
        action = "transform";
215
      //} else {
216
      //  action = "";
217
      }
218
    } catch (Exception npe) {
219
      //out.println("<P>Caught exception looking for Y value.");
201
    
202
    //if the user clicked on the input images, decode which image
203
    //was clicked then set the action.
204
    String action = decodeMouseAction(params);
205
    if(action.equals("error"))
206
    {
207
      action = ((String[])params.get("action"))[0];  
220 208
    }
221

  
209
    
222 210
// Jivka added  
223 211
    // handle login action
224 212
    if (action.equals("Login") || action.equals("Login Client")) {
......
277 265
    // Close the stream to the client
278 266
    out.close();
279 267
  }
268
  
269
  /**
270
   * decodes the mouse click information coming from the client.
271
   * This function may be overwritten to provide specific functionality
272
   * for different applications.
273
   * @param params the parameters from the CGI
274
   * @return action the action to be performed or "error" if an error was
275
   * generated
276
   */
277
  private String decodeMouseAction(Hashtable params)
278
  {
279
    // Determine what type of request the user made
280
    // if the action parameter is set, use it as a default
281
    // but if the ypos param is set, calculate the action needed
282
    String action=null;
283
    long ypos = 0;
284
    try {
285
      ypos = (new Long(((String[])params.get("ypos"))[0]).longValue());
286
      //out.println("<P>YPOS IS " + ypos);
287
      if (ypos <= 13) {
288
        action = "getdocument";
289
      } else if (ypos > 13 && ypos <= 27) {
290
        action = "validate";
291
      } else if (ypos > 27) {
292
        action = "transform";
293
      }
294
      return action;
295
    } catch (Exception npe) {
296
      //out.println("<P>Caught exception looking for Y value.");
297
      return "error";
298
    } 
299
  }
280 300

  
281 301
// Jivka added
282 302
  /** 
......
455 475
    }    
456 476
  }
457 477
  
478
  /**
479
   * Transforms a hashtable of documents to an xml or html result.
480
   * @param doclist- the hashtable to transform
481
   * @param qformat- the format to transform the results into
482
   * @param xmlquery- the query that returned the dolist result
483
   * @param out- the printwriter object used to write to the client
484
   * @param response- the response stream to write back to the client.
485
   */
458 486
  private void transformDocument(Hashtable doclist, String qformat, 
459 487
                                 String xmlquery, PrintWriter out,
460 488
                                 HttpServletResponse response)
......
900 928

  
901 929
/**
902 930
 * '$Log$
931
 * 'Revision 1.68  2000/08/14 21:28:54  berkley
932
 * 'Broke up handleQueryAction into handleQuery, handleSQuery, runQuery and transformDocument.  handleQueryAction is now a base function which makes calls to each of these functions to create, run and transform a query from CGI parameters.
933
 * '
903 934
 * 'Revision 1.67  2000/08/14 20:43:27  jones
904 935
 * 'Updated build process to now use a copy of the source files so that keyword
905 936
 * 'substitution can ocur before the build.  This allows for substitution of

Also available in: Unified diff