Project

General

Profile

« Previous | Next » 

Revision 536

Added by berkley about 24 years ago

changed action scheme

View differences:

src/edu/ucsb/nceas/metacat/MetacatReplication.java
83 83
      params.put(name, value);  
84 84
    }
85 85
    
86
    if(params.containsKey("stop"))
86
    if(params.containsKey("action"))
87 87
    {
88
      if(((String[])params.get("stop"))[0].equals("true"))
88
      if(((String[])params.get("action"))[0].equals("stop"))
89 89
      {  
90 90
        replicationDaemon.cancel();
91 91
        out.println("Replication Handler Stopped");
92 92
      }
93
    }
94
    
95
    if(params.containsKey("start"))
96
    {
97
      if(((String[])params.get("start"))[0].equals("true"))
93
      else if(((String[])params.get("action"))[0].equals("start"))
98 94
      {
99 95
        int rate;
100 96
        if(params.containsKey("rate"))
......
110 106
                                              rate * 1000);
111 107
        out.println("Replication Handler Started");
112 108
      }
109
      else if(((String[])params.get("action"))[0].equals("update"))
110
      {
111
        handleUpdateRequest(out, params, response);
112
      }
113
      else if(((String[])params.get("action"))[0].equals("update"))
114
      {
115
        handleGetDocumentRequest(out, params, response);
116
      }
113 117
    }
114
    
115
    if(params.containsKey("update"))
116
    {
117
      handleUpdateRequest(out, params, response);
118
    }
119
    
120
    if(params.containsKey("getdocument"))
121
    {
122
      handleGetDocumentRequest(out, params, response);
123
    }
124 118
  }
125 119
  
126 120
  private void handleGetDocumentRequest(PrintWriter out, Hashtable params, 
......
128 122
  {
129 123
    try
130 124
    {
131
      String docid = ((String[])(params.get("getdocument")))[0];
125
      String docid = ((String[])(params.get("docid")))[0];
132 126
      System.out.println("incoming get request for document: " +
133 127
                         docid);
134 128
      Connection conn = util.openDBConnection();
......
148 142
                                   HttpServletResponse response)
149 143
  {
150 144
    System.out.println("incoming update request for dt/time " + 
151
                       ((String[])params.get("update"))[0] +
145
                       ((String[])params.get("date"))[0] +
152 146
                       " from external metacat");
153 147
    response.setContentType("text/xml");
154 148
    out.println("<replication><textmessage>In metacatReplication</textmessage>");
155 149
    
156 150
    StringBuffer sql = new StringBuffer();
157 151
    StringBuffer returnXML = new StringBuffer();
158
    String updateStr = ((String[])params.get("update"))[0];
152
    String updateStr = ((String[])params.get("date"))[0];
159 153
    updateStr = updateStr.replace('+', ' ');
160 154
    //pseudo algorithm:
161 155
    ///////////////////////////////////////////////////////////////////////
src/edu/ucsb/nceas/metacat/ReplicationHandler.java
111 111
        
112 112
        update = update.replace(' ', '+');
113 113
        
114
        u = new URL("http://" + server + "?update=" + update);
114
        u = new URL("http://" + server + "?action=update&date=" + update);
115 115
        istream = new InputStreamReader(u.openStream());
116 116
        while((istreamInt = istream.read()) != -1)
117 117
        {
......
137 137
          String docServer = (String)w.elementAt(2);
138 138

  
139 139
          //send a message to the server requesting each document
140
          URL getDocURL = new URL("http://" + docServer + "?getdocument="+
141
                      docid);
140
          URL getDocURL = new URL("http://" + docServer + 
141
                                  "?action=getdocument&docid="+ docid);
142 142
          InputStreamReader getDocIstream = new InputStreamReader(
143 143
                                                getDocURL.openStream());
144 144

  

Also available in: Unified diff