Project

General

Profile

« Previous | Next » 

Revision 2822

Added by Duane Costa over 18 years ago

Eliminate hard-coding of the knb context from the advanced search code. Advanced search servlet determines the metacat context name by reading the metacat.properties file at servlet initialization.

View differences:

MetacatHelper.java
51 51
  
52 52

  
53 53
  /**
54
   * Constructs a URL to the metacat servlet. Assumes that metacat is always
55
   * configured to run in the "knb" context (the defacto standard).
54
   * Constructs a URL to the metacat servlet.
56 55
   * 
57 56
   * @param serverName   A server name, e.g. "prairie.lternet.edu"
58 57
   * @param serverPort   A server port, e.g. 8080. If no port is required in
59 58
   *                     the URL, pass a 0 and the argument will be ignored.
59
   * @param contextString The context under which metacat is running, e.g. "knb".
60 60
   * @return metacatURL  The URL to the metacat servlet.
61 61
   */
62 62
  public String constructMetacatURL(final String serverName, 
63
                                    final int serverPort) {
63
                                    final int serverPort,
64
                                    final String contextString) {
64 65
    String metacatURL = "http://" + serverName;
65 66
    
66 67
    if (serverPort > 0) {
67 68
      final Integer serverPortInteger = new Integer(serverPort);
68 69
      final String serverPortString = serverPortInteger.toString();
69
      metacatURL += ":" + serverPortString + "/knb/metacat";
70
      metacatURL += ":" + serverPortString;
70 71
    }
71
    else {
72
      metacatURL += "/knb/metacat";
73
    }
74 72
    
73
    metacatURL += "/" + contextString + "/metacat";
74

  
75 75
    return metacatURL;
76 76
  }
77 77

  

Also available in: Unified diff