@RequestMapping(value = "/cobranza/caso/{numeroCaso}", method = RequestMethod.GET) public String ver( @PathVariable String numeroCaso, Model model, RedirectAttributes redirectAttributes, Principal principal) { sesionSetEmpleado(principal); List<String> mensajes = Utils.getFlashMensajes(model, redirectAttributes); try { sesionSetCaso(numeroCaso); } catch (CancelacionWebException ex) { mensajes.add("warning::Caso asignado a Gerente de Juridico"); return "redirect:/"; } catch (NullPointerException ex) { mensajes.add("warning::El caso " + numeroCaso + " no existe."); return "redirect:/"; } CasoInfo caso = sesion.getCaso(); model.addAttribute("caso", caso); ProyectoCancelacionInfo proyecto = sesion.getProyectoCancelacion(); model.addAttribute("proyecto", proyecto); if (proyecto == null) { model.addAttribute("archivos", new ArrayList<CancelacionArchivoInfo>()); } else { ListResponse<CancelacionArchivoInfo> list1 = cancelacionArchivoService.list( new ListRequest("proyectoCancelacionId", proyecto.getId())); model.addAttribute("archivos", list1.getList()); ListResponse<EmpleadoInfo> list2 = empleadoService.listarGerentesJuridico(); model.addAttribute("jefesj", list2.getList()); } return "/jcobranza/ver"; }
/** * Returns the next page for the given {@link ListResponse}. Returns null if it was the last page. * * @param response The {@ListResponse} obtained through a call to {@link #list(String, Map)} or * {@link #nextPage(ListResponse)} * @return A {@link ListResponse} with the results */ public ListResponse nextPage(ListResponse response) throws ApiException { if (response.isLastPage()) { return null; } Map<String, String> params = response.getRequestParams(); params.put("page", String.valueOf(Integer.valueOf(params.get("page")) + 1)); return this.list(response.getEndpoint(), params); }
@Override public ArrayList<Department> handleResponse(HttpResponse response) throws ClientProtocolException, IOException { // parse the JSON and put the data in the arrayList HttpEntity httpEntity = response.getEntity(); // InputStream inputStream = httpEntity.getContent(); String jsonStr = EntityUtils.toString(httpEntity); LineNumberReader lnr = new LineNumberReader(new StringReader(jsonStr)); String currentString; while ((currentString = lnr.readLine()) != null) { // Log.v("TeamLeader", "httpResponse:" + currentString); } try { JSONArray jsonArray = new JSONArray(jsonStr); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jSonP = jsonArray.getJSONObject(i); Department department = new Department(); department.setId(jSonP.getInt("id")); department.setName(jSonP.getString("name")); departments.add(department); } } catch (JSONException e) { if (e.getMessage().contains("No value for")) {} e.printStackTrace(); } fillView.setList(departments); return departments; }
public String toString(String prefix) { StringBuffer sb = new StringBuffer(); sb.append(prefix).append("path: ").append(path).append('\n'); sb.append(prefix).append("disp: ").append(displayname).append('\n'); sb.append(prefix).append("coll: ").append(isCollection).append('\n'); sb.append(prefix).append("uid: ").append(uid).append('\n'); sb.append(prefix).append("gid: ").append(gid).append('\n'); sb.append(prefix).append("mode: ").append(mode).append('\n'); if (contents != null) { Iterator it = contents.iterator(); while (it.hasNext()) { ListResponse lr = (ListResponse) it.next(); sb.append(lr.toString(" ")); } } return sb.toString(); }
public CmdResult list(String path, int depth, boolean detailed) throws HoneycombTestException { CmdResult cr = new CmdResult(); LinkedList files = new java.util.LinkedList(); // set up query StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); sb.append("<D:propfind XMLNS:D=\"DAV:\">"); if (detailed) sb.append("<D:allprop/>"); // names & values else sb.append("<D:propname/>"); // names only sb.append("</D:propfind>"); byte[] qbuf = getUTF8Bytes(sb.toString()); NVPair[] headers = new NVPair[4]; headers[0] = CLIENT; if (depth < 0) headers[1] = new NVPair("depth", "infinity"); else headers[1] = new NVPair("depth", Integer.toString(depth)); headers[2] = new NVPair("Content-type", "text/xml"); headers[3] = new NVPair("Content-length", Integer.toString(qbuf.length)); try { // // query // long t1 = System.currentTimeMillis(); HTTPResponse rsp = conn.ExtensionMethod("PROPFIND", path, qbuf, headers); cr.time = System.currentTimeMillis() - t1; if (rsp.getStatusCode() >= 300) throw makeTestException("list", path, rsp); cr.pass = true; // // parse response // cr.string = new String(rsp.getData()); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(cr.string)); List l = doc.getContent(); Iterator it = l.iterator(); Element root = null; int ct = 0; while (it.hasNext()) { ct++; root = (Element) it.next(); } if (ct != 1) throw new HoneycombTestException("Expected 1 content element, got " + ct); if (!root.getName().equals("multistatus")) throw new HoneycombTestException("Expected multistatus, got " + root.getName()); l = root.getAttributes(); if (l.size() != 0) throw new HoneycombTestException("Unexpected: root elt has attributes"); cr.count = 0; cr.list = new java.util.LinkedList(); l = root.getChildren(); it = l.iterator(); while (it.hasNext()) { cr.count++; Element e = (Element) it.next(); if (!e.getName().equals("response")) throw new HoneycombTestException("Unexpected: child: " + e.getName()); // // parse this response element // // response.href Element href = e.getChild("href", XMLNS); if (href == null) throw new HoneycombTestException("No href: " + e); String epath = href.getValue(); if (epath == null) throw new HoneycombTestException("empty href: " + e); int ix = epath.indexOf("/webdav"); if (ix == -1) throw new HoneycombTestException("href missing '/webdav': " + e); epath = epath.substring(ix); // Log.INFO("href.path: " + epath); // response.propstat Element propstat = e.getChild("propstat", XMLNS); if (propstat == null) throw new HoneycombTestException("No propstat (" + epath + "): " + e); // response.propstat.status Element status = propstat.getChild("status", XMLNS); if (status == null) throw new HoneycombTestException("No status (" + epath + "): " + e); String estatus = status.getValue(); if (!estatus.equals("HTTP/1.1 200 OK")) throw new HoneycombTestException("Bad status (" + estatus + "): " + e); // response.propstat.prop Element prop = propstat.getChild("prop", XMLNS); if (prop == null) throw new HoneycombTestException("No prop (" + epath + "): " + e); boolean isCollection = false; Element rtype = prop.getChild("resourcetype", XMLNS); if (rtype != null) { Element coll = rtype.getChild("collection", XMLNS); if (coll == null) throw new HoneycombTestException("Resourcetype != collection: " + rtype); isCollection = true; } String ecttype = null; Element cttype = prop.getChild("getcontenttype", XMLNS); if (cttype == null) Log.WARN("No getcontenttype: " + epath); else ecttype = cttype.getValue(); String emode = null; Element mode = prop.getChild("mode", null); if (mode != null) emode = mode.getValue(); Element displayname = prop.getChild("displayname", XMLNS); if (displayname == null) throw new HoneycombTestException("displayname is null (" + epath + "): " + e); String edisplayname = displayname.getValue(); Element create = prop.getChild("creationdate", XMLNS); if (create == null) throw new HoneycombTestException("creationdate is null (" + epath + "): " + e); String ecreate = create.getValue(); Element length = prop.getChild("getcontentlength", XMLNS); if (length == null) throw new HoneycombTestException("getcontentlength is null (" + epath + "): " + e); long llength = Long.parseLong(length.getValue()); // different for dir vs. node String eoid = null; String lastmod = null; int uid = -1; int gid = -1; if (!isCollection) { Element el = prop.getChild("hc-oid", XMLNS); if (el != null) eoid = el.getValue(); el = prop.getChild("getlastmodified", XMLNS); if (el == null) throw new HoneycombTestException( "Not collection but no getlastmodified (" + epath + "): " + e); lastmod = el.getValue(); el = prop.getChild("uid", null); if (el != null) uid = Integer.parseInt(el.getValue()); el = prop.getChild("gid", null); if (el != null) gid = Integer.parseInt(el.getValue()); } // // consistency checks // if (isCollection && (ecttype == null || !ecttype.equals("httpd/unix-directory"))) throw new HoneycombTestException( "Collection but getcontenttype is " + ecttype + " (" + epath + "): " + e); // // add to list // ListResponse lr = new ListResponse( epath, isCollection, ecttype, edisplayname, emode, ecreate, llength, eoid, lastmod, uid, gid); if (isCollection) cr.list.add(lr); else files.add(lr); } } catch (HoneycombTestException e) { throw e; } catch (Exception e) { // Log.ERROR("ex: " + e); // e.printStackTrace(); cr.pass = false; cr.addException(e); } // // sort files into directories => note that // directories are not nested // Iterator it = files.iterator(); while (it.hasNext()) { ListResponse lr = (ListResponse) it.next(); // // '/' is escaped in attributes, so lastIndexOf('/') // is really the end of the dirs and not e.g. a mimetime // '/' as in "app/xxx". // String dirPath = lr.path.substring(0, lr.path.lastIndexOf('/') + 1); Iterator it2 = cr.list.iterator(); while (it2.hasNext()) { ListResponse lr2 = (ListResponse) it2.next(); if (lr2.path.equals(dirPath)) { it.remove(); lr2.addFile(lr); break; } } } // shouldn't be any files left over, but just in case if (files.size() > 0) { if (cr.list.size() > 0) { it = files.iterator(); while (it.hasNext()) { ListResponse lr = (ListResponse) it.next(); Log.INFO("orphan: " + lr.path); } } cr.list.addAll(files); } return cr; }
void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException { if (!connection.hasCapability(Capabilities.SPECIAL_USE)) { if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "No detected folder auto-configuration methods."); } return; } if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration: Using RFC6154/SPECIAL-USE."); } String command = String.format( "LIST (SPECIAL-USE) \"\" %s", ImapUtility.encodeString(getCombinedPrefix() + "*")); List<ImapResponse> responses = connection.executeSimpleCommand(command); List<ListResponse> listResponses = ListResponse.parseList(responses); for (ListResponse listResponse : listResponses) { String decodedFolderName; try { decodedFolderName = folderNameCodec.decode(listResponse.getName()); } catch (CharacterCodingException e) { Log.w( LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " + "as defined by RFC 3501: " + listResponse.getName(), e); // We currently just skip folders with malformed names. continue; } if (pathDelimiter == null) { pathDelimiter = listResponse.getHierarchyDelimiter(); combinedPrefix = null; } if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) { mStoreConfig.setArchiveFolderName(decodedFolderName); if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration detected Archive folder: " + decodedFolderName); } } else if (listResponse.hasAttribute("\\Drafts")) { mStoreConfig.setDraftsFolderName(decodedFolderName); if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration detected Drafts folder: " + decodedFolderName); } } else if (listResponse.hasAttribute("\\Sent")) { mStoreConfig.setSentFolderName(decodedFolderName); if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration detected Sent folder: " + decodedFolderName); } } else if (listResponse.hasAttribute("\\Junk")) { mStoreConfig.setSpamFolderName(decodedFolderName); if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration detected Spam folder: " + decodedFolderName); } } else if (listResponse.hasAttribute("\\Trash")) { mStoreConfig.setTrashFolderName(decodedFolderName); if (K9MailLib.isDebug()) { Log.d(LOG_TAG, "Folder auto-configuration detected Trash folder: " + decodedFolderName); } } } }
private Set<String> listFolders(ImapConnection connection, boolean subscribedOnly) throws IOException, MessagingException { String commandResponse = subscribedOnly ? "LSUB" : "LIST"; List<ImapResponse> responses = connection.executeSimpleCommand( String.format( "%s \"\" %s", commandResponse, ImapUtility.encodeString(getCombinedPrefix() + "*"))); List<ListResponse> listResponses = (subscribedOnly) ? ListResponse.parseLsub(responses) : ListResponse.parseList(responses); Set<String> folderNames = new HashSet<>(listResponses.size()); for (ListResponse listResponse : listResponses) { boolean includeFolder = true; String decodedFolderName; try { decodedFolderName = folderNameCodec.decode(listResponse.getName()); } catch (CharacterCodingException e) { Log.w( LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " + "as defined by RFC 3501: " + listResponse.getName(), e); // TODO: Use the raw name returned by the server for all commands that require // a folder name. Use the decoded name only for showing it to the user. // We currently just skip folders with malformed names. continue; } String folder = decodedFolderName; if (pathDelimiter == null) { pathDelimiter = listResponse.getHierarchyDelimiter(); combinedPrefix = null; } if (folder.equalsIgnoreCase(mStoreConfig.getInboxFolderName())) { continue; } else if (folder.equals(mStoreConfig.getOutboxFolderName())) { /* * There is a folder on the server with the same name as our local * outbox. Until we have a good plan to deal with this situation * we simply ignore the folder on the server. */ continue; } else { int prefixLength = getCombinedPrefix().length(); if (prefixLength > 0) { // Strip prefix from the folder name if (folder.length() >= prefixLength) { folder = folder.substring(prefixLength); } if (!decodedFolderName.equalsIgnoreCase(getCombinedPrefix() + folder)) { includeFolder = false; } } } if (listResponse.hasAttribute("\\NoSelect")) { includeFolder = false; } if (includeFolder) { folderNames.add(folder); } } folderNames.add(mStoreConfig.getInboxFolderName()); return folderNames; }
@Override public List<GroupListItem> list() { NntpFuture<ListResponse> future = this.sendCommand(Response.ResponseType.LIST); ListResponse response = Futures.getUnchecked(future); return response.getItems(); }