Пример #1
0
 /**
  * Check if the server is ok
  *
  * @return status code
  */
 protected int checkIfServerIsOk() {
   try {
     StringBuffer buff = getUrl(REQ_TEXT);
     appendKeyValue(buff, PROP_FILE, FILE_PUBLICSRV);
     URL url = new URL(buff.toString());
     URLConnection urlc = url.openConnection();
     InputStream is = urlc.getInputStream();
     is.close();
     return STATUS_OK;
   } catch (AddeURLException ae) {
     String aes = ae.toString();
     if (aes.indexOf("Invalid project number") >= 0) {
       LogUtil.userErrorMessage("Invalid project number");
       return STATUS_NEEDSLOGIN;
     }
     if (aes.indexOf("Invalid user id") >= 0) {
       LogUtil.userErrorMessage("Invalid user ID");
       return STATUS_NEEDSLOGIN;
     }
     if (aes.indexOf("Accounting data") >= 0) {
       return STATUS_NEEDSLOGIN;
     }
     if (aes.indexOf("cannot run server 'txtgserv") >= 0) {
       return STATUS_OK;
     }
     LogUtil.userErrorMessage("Error connecting to server. " + ae.getMessage());
     return STATUS_ERROR;
   } catch (Exception exc) {
     logException("Connecting to server:" + getServer(), exc);
     return STATUS_ERROR;
   }
 }
Пример #2
0
 /**
  * A utility method to make a name=value part of the adde request string
  *
  * @param buf The buffer to append to
  * @param name The property name
  * @param value The value
  */
 protected void appendKeyValue(StringBuffer buf, String name, String value) {
   if ((buf.length() == 0) || (buf.charAt(buf.length() - 1) != '?')) {
     buf.append("&");
   }
   buf.append(name);
   buf.append("=");
   buf.append(value);
 }
Пример #3
0
 /**
  * Read the groups from the public.srv file on the server
  *
  * @return List of groups
  */
 protected List readGroups() {
   List groups = new ArrayList();
   try {
     String dataType = getDataType();
     String type = ((dataType.length() > 0) ? "TYPE=" + dataType : "TYPE=NOTYPE");
     StringBuffer buff = getUrl(REQ_TEXT);
     appendKeyValue(buff, PROP_FILE, FILE_PUBLICSRV);
     List lines = readTextLines(buff.toString());
     //            System.err.println ("lines:" + StringUtil.join("\n",lines));
     if (lines == null) {
       return null;
     }
     Hashtable seen = new Hashtable();
     for (int i = 0; i < lines.size(); i++) {
       String line = lines.get(i).toString();
       if (line.indexOf(type) < 0) {
         continue;
       }
       List toks = StringUtil.split(line, ",", true, true);
       if (toks.size() == 0) {
         continue;
       }
       String tok = (String) toks.get(0);
       int idx = tok.indexOf("=");
       if (idx < 0) {
         continue;
       }
       if (!tok.substring(0, idx).trim().equals("N1")) {
         continue;
       }
       String group = tok.substring(idx + 1).trim();
       if (seen.get(group) != null) {
         continue;
       }
       seen.put(group, group);
       groups.add(group);
     }
   } catch (Exception e) {
     return null;
   }
   return groups;
 }
Пример #4
0
 /**
  * Get the miscellaneous URL keywords
  *
  * @return the key value pairs
  */
 public String getMiscKeywords() {
   StringBuffer buff = new StringBuffer();
   appendMiscKeyValues(buff);
   return buff.toString();
 }