Esempio n. 1
0
 /**
  * Checks if the produced content type matches.
  *
  * @param http http context
  * @return result of check
  */
 private boolean produces(final HTTPContext http) {
   // return true if no type is given
   if (produces.isEmpty()) return true;
   // check if any combination matches
   for (final String pr : http.produces()) {
     for (final String p : produces) {
       if (MimeTypes.matches(p, pr)) return true;
     }
   }
   return false;
 }
Esempio n. 2
0
 /**
  * Checks if the consumed content type matches.
  *
  * @param http http context
  * @return result of check
  */
 private boolean consumes(final HTTPContext http) {
   // return true if no type is given
   if (consumes.isEmpty()) return true;
   // return true if no content type is specified by the user
   final String ct = http.contentType();
   if (ct == null) return true;
   // check if any combination matches
   for (final String c : consumes) {
     if (MimeTypes.matches(c, ct)) return true;
   }
   return false;
 }
Esempio n. 3
0
 /**
  * Refreshes the list of recent query files and updates the query path.
  *
  * @param file new file
  */
 void refreshHistory(final IOFile file) {
   final StringList sl = new StringList();
   String path = null;
   if (file != null) {
     path = file.path();
     gui.gprop.set(GUIProp.WORKPATH, file.dirPath());
     sl.add(path);
     tabs.setToolTipTextAt(tabs.getSelectedIndex(), path);
   }
   final String[] qu = gui.gprop.strings(GUIProp.EDITOR);
   for (int q = 0; q < qu.length && q < 19; q++) {
     final String f = qu[q];
     if (!f.equalsIgnoreCase(path) && IO.get(f).exists()) sl.add(f);
   }
   // store sorted history
   gui.gprop.set(GUIProp.EDITOR, sl.toArray());
   hist.setEnabled(!sl.isEmpty());
 }
Esempio n. 4
0
 /**
  * Gets active locks for the given resource.
  *
  * @param db database
  * @param path path
  * @return locks
  * @throws IOException I/O exception
  */
 public String lock(final String db, final String path) throws IOException {
   final WebDAVQuery query = new WebDAVQuery("w:locks-on($path)").bind("path", db + SEP + path);
   final StringList sl = execute(query);
   return sl.isEmpty() ? null : sl.get(0);
 }
Esempio n. 5
0
 /**
  * Gets lock with given token.
  *
  * @param token lock token
  * @return lock
  * @throws IOException I/O exception
  */
 public String lock(final String token) throws IOException {
   final StringList locks = execute(new WebDAVQuery("w:lock($token)").bind("token", token));
   return locks.isEmpty() ? null : locks.get(0);
 }