Example usage for java.text DateFormat setTimeZone

List of usage examples for java.text DateFormat setTimeZone

Introduction

In this page you can find the example usage for java.text DateFormat setTimeZone.

Prototype

public void setTimeZone(TimeZone zone) 

Source Link

Document

Sets the time zone for the calendar of this DateFormat object.

Usage

From source file:com.krawler.spring.crm.dashboard.CrmDashboardController.java

private void processAuditLogData(HttpServletRequest request, List<KwlReturnObject> results,
        List<Map<String, Object>> requestParamsList)
        throws SessionExpiredException, ServiceException, JSONException {
    int i = 0;//from www  .j  a v a 2 s.  c om
    String tZStr = sessionHandlerImpl.getTimeZoneDifference(request);

    DateFormat df = authHandler.getDateFormatter(authHandler.getUserTimeFormat(request));
    if (tZStr != null) {
        TimeZone zone = TimeZone.getTimeZone("GMT" + tZStr);
        df.setTimeZone(zone);
    }

    Map<String, KwlReturnObject> resultMap = new HashMap<String, KwlReturnObject>();

    for (KwlReturnObject kmsg : results) {
        resultMap.put(kmsg.getMsg(), kmsg);
    }

    for (Map<String, Object> params : requestParamsList) {
        KwlReturnObject kmsg = resultMap.get((String) params.get("groups"));

        if (kmsg == null) {
            continue;
        }
        int type = (Integer) params.get("type");
        List<DashboardUpdate> auditTrailList = kmsg.getEntityList();
        List<String> updateDivList = new ArrayList<String>();

        Map<String, List<AuditTrailDetail>> auditTrailDetailMap = new HashMap<String, List<AuditTrailDetail>>();
        List<String> recordIds = new ArrayList<String>();
        List<AuditTrailDetail> origList = new ArrayList<AuditTrailDetail>();
        WidgetUpdateData wData = new WidgetUpdateData();
        if (type != 8) {
            if (auditTrailList != null) {
                for (DashboardUpdate auditTrailArr : auditTrailList) {
                    // TODO Fixme
                    AuditTrailDetail auditTrailDetail = new AuditTrailDetail();
                    auditTrailDetail.userName = getFullName(auditTrailArr.getFirstName(),
                            auditTrailArr.getLastName());
                    auditTrailDetail.userId = auditTrailArr.getUserId();
                    String recId = auditTrailArr.getRecid();
                    auditTrailDetail.recId = recId;

                    String details = auditTrailArr.getDetails();
                    recordIds.add(recId);
                    try {
                        auditTrailDetail.detail = URLDecoder.decode(details);

                    } catch (Exception e) {
                        auditTrailDetail.detail = details;
                    }

                    if (auditTrailDetailMap.containsKey(recId)) {
                        List<AuditTrailDetail> list = auditTrailDetailMap.get(recId);
                        list.add(auditTrailDetail);
                    } else {
                        List<AuditTrailDetail> list = new ArrayList<AuditTrailDetail>();
                        list.add(auditTrailDetail);
                        auditTrailDetailMap.put(recId, list);
                    }

                    // set time
                    Long auditTimeLong = (Long) auditTrailArr.getAuditTime();
                    Date auditTime = null;
                    if (auditTimeLong != null) {
                        auditTime = new Date(auditTimeLong);
                    }
                    if (auditTime != null) {
                        try {
                            auditTrailDetail.time = df.format(auditTime);
                        } catch (Exception e) {
                        }
                    }
                    origList.add(auditTrailDetail);
                }
            }

            switch (type) {
            case 0:
                getCampaigns(auditTrailDetailMap, recordIds);
                break;
            case 1:
                getLeads(auditTrailDetailMap, recordIds);
                break;
            case 2:
                getAccounts(auditTrailDetailMap, recordIds);
                break;
            case 3:
                getContacts(auditTrailDetailMap, recordIds);
                break;
            case 4:
                getOpportunities(auditTrailDetailMap, recordIds);
                break;
            case 5:
                getCases(auditTrailDetailMap, recordIds);
                break;
            case 6:
                getActivities(auditTrailDetailMap, recordIds);
                break;
            case 7:
                getProducts(auditTrailDetailMap, recordIds);
                break;
            }

            for (AuditTrailDetail detail : origList) {
                setAuditInfo(detail);
                if (detail.updateDiv != null) {
                    updateDivList.add(detail.updateDiv);
                } else if (detail.detail != null) {
                    updateDivList.add(detail.detail);
                }
            }

            wData.data = updateDivList;
            wData.count = kmsg.getRecordTotalCount();

        } else {
            int start = (Integer) params.get("start");
            int limit = (Integer) params.get("limit");
            StringBuffer usersList = new StringBuffer();
            if (params.containsKey("userslist")) {
                usersList = (StringBuffer) params.get("userslist");
            }
            int count = getTopActivities(updateDivList, usersList, df, tZStr, start, limit);
            wData.count = count;
            wData.data = updateDivList;
        }
        params.put("widgetData", wData);

    }
}

From source file:net.wastl.webmail.server.WebMailSession.java

/**
 * Fetch a message from a folder.//from ww  w .  ja  va 2  s .  c  o  m
 * Will put the messages parameters in the sessions environment
 *
 * @param foldername Name of the folder were the message should be fetched from
 * @param msgnum Number of the message to fetch
 * @param mode there are three different modes: standard, reply and forward. reply and forward will enter the message
 *             into the current work element of the user and set some additional flags on the message if the user
 *             has enabled this option.
 * @see net.wastl.webmail.server.WebMailSession.GETMESSAGE_MODE_STANDARD
 * @see net.wastl.webmail.server.WebMailSession.GETMESSAGE_MODE_REPLY
 * @see net.wastl.webmail.server.WebMailSession.GETMESSAGE_MODE_FORWARD
 */
public void getMessage(String folderhash, int msgnum, int mode) throws NoSuchFolderException, WebMailException {
    // security reasons:
    // attachments=null;

    try {
        TimeZone tz = TimeZone.getDefault();
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT,
                user.getPreferredLocale());
        df.setTimeZone(tz);
        Folder folder = getFolder(folderhash);
        Element xml_folder = model.getFolder(folderhash);

        if (folder == null) {
            throw new NoSuchFolderException("No such folder: " + folderhash);
        }

        if (folder.isOpen() && folder.getMode() == Folder.READ_WRITE) {
            folder.close(false);
            folder.open(Folder.READ_ONLY);
        } else if (!folder.isOpen()) {
            folder.open(Folder.READ_ONLY);
        }

        MimeMessage m = (MimeMessage) folder.getMessage(msgnum);

        String messageid;
        try {
            StringTokenizer tok = new StringTokenizer(m.getMessageID(), "<>");
            messageid = tok.nextToken();
        } catch (NullPointerException ex) {
            // For mail servers that don't generate a Message-ID (Outlook et al)
            messageid = user.getLogin() + "." + msgnum + ".jwebmail@" + user.getDomain();
        }

        Element xml_current = model.setCurrentMessage(messageid);
        XMLMessage xml_message = model.getMessage(xml_folder, m.getMessageNumber() + "", messageid);

        /* Check whether we already cached this message (not only headers but complete)*/
        boolean cached = xml_message.messageCompletelyCached();
        /* If we cached the message, we don't need to fetch it again */
        if (!cached) {
            //Element xml_header=model.getHeader(xml_message);

            try {
                String from = MimeUtility.decodeText(Helper.joinAddress(m.getFrom()));
                String replyto = MimeUtility.decodeText(Helper.joinAddress(m.getReplyTo()));
                String to = MimeUtility
                        .decodeText(Helper.joinAddress(m.getRecipients(Message.RecipientType.TO)));
                String cc = MimeUtility
                        .decodeText(Helper.joinAddress(m.getRecipients(Message.RecipientType.CC)));
                String bcc = MimeUtility
                        .decodeText(Helper.joinAddress(m.getRecipients(Message.RecipientType.BCC)));
                Date date_orig = m.getSentDate();
                String date = getStringResource("no date");
                if (date_orig != null) {
                    date = df.format(date_orig);
                }
                String subject = "";
                if (m.getSubject() != null) {
                    subject = MimeUtility.decodeText(m.getSubject());
                }
                if (subject == null || subject.equals("")) {
                    subject = getStringResource("no subject");
                }

                try {
                    Flags.Flag[] sf = m.getFlags().getSystemFlags();
                    for (int j = 0; j < sf.length; j++) {
                        if (sf[j] == Flags.Flag.RECENT)
                            xml_message.setAttribute("recent", "true");
                        if (sf[j] == Flags.Flag.SEEN)
                            xml_message.setAttribute("seen", "true");
                        if (sf[j] == Flags.Flag.DELETED)
                            xml_message.setAttribute("deleted", "true");
                        if (sf[j] == Flags.Flag.ANSWERED)
                            xml_message.setAttribute("answered", "true");
                        if (sf[j] == Flags.Flag.DRAFT)
                            xml_message.setAttribute("draft", "true");
                        if (sf[j] == Flags.Flag.FLAGGED)
                            xml_message.setAttribute("flagged", "true");
                        if (sf[j] == Flags.Flag.USER)
                            xml_message.setAttribute("user", "true");
                    }
                } catch (NullPointerException ex) {
                }
                if (m.getContentType().toUpperCase().startsWith("MULTIPART/")) {
                    xml_message.setAttribute("attachment", "true");
                }

                int size = m.getSize();
                size /= 1024;
                xml_message.setAttribute("size", (size > 0 ? size + "" : "<1") + " kB");

                /* Set all of what we found into the DOM */
                xml_message.setHeader("FROM", from);
                xml_message.setHeader("SUBJECT", Fancyfier.apply(subject));
                xml_message.setHeader("TO", to);
                xml_message.setHeader("CC", cc);
                xml_message.setHeader("BCC", bcc);
                xml_message.setHeader("REPLY-TO", replyto);
                xml_message.setHeader("DATE", date);

                /* Decode MIME contents recursively */
                xml_message.removeAllParts();
                parseMIMEContent(m, xml_message, messageid);

            } catch (UnsupportedEncodingException e) {
                log.warn("Unsupported Encoding in parseMIMEContent: " + e.getMessage());
            }
        }
        /* Set seen flag (Maybe make that threaded to improve performance) */
        if (user.wantsSetFlags()) {
            if (folder.isOpen() && folder.getMode() == Folder.READ_ONLY) {
                folder.close(false);
                folder.open(Folder.READ_WRITE);
            } else if (!folder.isOpen()) {
                folder.open(Folder.READ_WRITE);
            }
            folder.setFlags(msgnum, msgnum, new Flags(Flags.Flag.SEEN), true);
            folder.setFlags(msgnum, msgnum, new Flags(Flags.Flag.RECENT), false);
            if ((mode & GETMESSAGE_MODE_REPLY) == GETMESSAGE_MODE_REPLY) {
                folder.setFlags(msgnum, msgnum, new Flags(Flags.Flag.ANSWERED), true);
            }
        }
        folder.close(false);

        /* In this part we determine whether the message was requested so that it may be used for
           further editing (replying or forwarding). In this case we set the current "work" message to the
           message we just fetched and then modifiy it a little (quote, add a "Re" to the subject, etc). */
        XMLMessage work = null;
        if ((mode & GETMESSAGE_MODE_REPLY) == GETMESSAGE_MODE_REPLY
                || (mode & GETMESSAGE_MODE_FORWARD) == GETMESSAGE_MODE_FORWARD) {
            log.debug("Setting work message!");
            work = model.setWorkMessage(xml_message);

            String newmsgid = WebMailServer.generateMessageID(user.getUserName());

            if (work != null && (mode & GETMESSAGE_MODE_REPLY) == GETMESSAGE_MODE_REPLY) {
                String from = work.getHeader("FROM");
                work.setHeader("FROM", user.getDefaultEmail());
                work.setHeader("TO", from);
                work.prepareReply(getStringResource("reply subject prefix"),
                        getStringResource("reply subject postfix"), getStringResource("reply message prefix"),
                        getStringResource("reply message postfix"));

            } else if (work != null && (mode & GETMESSAGE_MODE_FORWARD) == GETMESSAGE_MODE_FORWARD) {
                String from = work.getHeader("FROM");
                work.setHeader("FROM", user.getDefaultEmail());
                work.setHeader("TO", "");
                work.setHeader("CC", "");
                work.prepareForward(getStringResource("forward subject prefix"),
                        getStringResource("forward subject postfix"),
                        getStringResource("forward message prefix"),
                        getStringResource("forward message postfix"));

                /* Copy all references to MIME parts to the new message id */
                for (String key : getMimeParts(work.getAttribute("msgid"))) {
                    StringTokenizer tok2 = new StringTokenizer(key, "/");
                    tok2.nextToken();
                    String newkey = tok2.nextToken();
                    mime_parts_decoded.put(newmsgid + "/" + newkey, mime_parts_decoded.get(key));
                }
            }

            /* Clear the msgnr and msgid fields at last */
            work.setAttribute("msgnr", "0");
            work.setAttribute("msgid", newmsgid);
            prepareCompose();
        }
    } catch (MessagingException ex) {
        log.error("Failed to get message.  Doing nothing instead.", ex);
    }
}

From source file:net.wastl.webmail.server.WebMailSession.java

/**
 * Create a Message List./*  www . j  av a  2 s .  c om*/
 * Fetches a list of headers in folder foldername for part list_part.
 * The messagelist will be stored in the "MESSAGES" environment.
 *
 * @param foldername folder for which a message list should be built
 * @param list_part part of list to display (1 = last xx messages, 2 = total-2*xx - total-xx messages)
 */
public void createMessageList(String folderhash, int list_part) throws NoSuchFolderException {
    long time_start = System.currentTimeMillis();
    TimeZone tz = TimeZone.getDefault();
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT,
            user.getPreferredLocale());
    df.setTimeZone(tz);

    try {
        Folder folder = getFolder(folderhash);
        Element xml_folder = model.getFolder(folderhash);
        Element xml_current = model.setCurrentFolder(folderhash);
        Element xml_messagelist = model.getMessageList(xml_folder);

        if (folder == null) {
            throw new NoSuchFolderException(folderhash);
        }

        long fetch_start = System.currentTimeMillis();

        if (!folder.isOpen()) {
            folder.open(Folder.READ_ONLY);
        } else {
            folder.close(false);
            folder.open(Folder.READ_ONLY);
        }

        /* Calculate first and last message to show */
        int total_messages = folder.getMessageCount();
        int new_messages = folder.getNewMessageCount();
        int show_msgs = user.getMaxShowMessages();

        xml_messagelist.setAttribute("total", total_messages + "");
        xml_messagelist.setAttribute("new", new_messages + "");

        log.debug("Total: " + total_messages);

        /* Handle small messagelists correctly */
        if (total_messages < show_msgs) {
            show_msgs = total_messages;
        }
        /* Don't accept list-parts smaller than 1 */
        if (list_part < 1) {
            list_part = 1;
        }
        for (int k = 0; k < list_part; k++) {
            total_messages -= show_msgs;
        }
        /* Handle beginning of message list */
        if (total_messages < 0) {
            total_messages = 0;
        }
        int first = total_messages + 1;
        int last = total_messages + show_msgs;
        /* Set environment variable */
        setEnv();
        xml_current.setAttribute("first_msg", first + "");
        xml_current.setAttribute("last_msg", last + "");
        xml_current.setAttribute("list_part", list_part + "");

        /* Fetch headers */
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        fp.add(FetchProfile.Item.FLAGS);
        fp.add(FetchProfile.Item.CONTENT_INFO);
        log.debug("Last: " + last + ", first: " + first);
        Message[] msgs = folder.getMessages(first, last);
        log.debug(msgs.length + " messages fetching...");
        folder.fetch(msgs, fp);
        long fetch_stop = System.currentTimeMillis();

        Map header = new Hashtable(15);

        Flags.Flag[] sf;
        String from, to, cc, bcc, replyto, subject;
        String messageid;

        for (int i = msgs.length - 1; i >= 0; i--) {
            //              if(((MimeMessage)msgs[i]).getMessageID() == null) {
            //                  folder.close(false);
            //                  folder.open(Folder.READ_WRITE);
            //                  ((MimeMessage)msgs[i]).setHeader("Message-ID","<"+user.getLogin()+"."+System.currentTimeMillis()+".jwebmail@"+user.getDomain()+">");
            //                  ((MimeMessage)msgs[i]).saveChanges();
            //                  folder.close(false);
            //                  folder.open(Folder.READ_ONLY);
            //              }

            try {
                StringTokenizer tok = new StringTokenizer(((MimeMessage) msgs[i]).getMessageID(), "<>");
                messageid = tok.nextToken();
            } catch (NullPointerException ex) {
                // For mail servers that don't generate a Message-ID (Outlook et al)
                messageid = user.getLogin() + "." + i + ".jwebmail@" + user.getDomain();
            }

            XMLMessage xml_message = model.getMessage(xml_folder, msgs[i].getMessageNumber() + "", messageid);

            /* Addresses */
            from = "";
            replyto = "";
            to = "";
            cc = "";
            bcc = "";
            try {
                from = MimeUtility.decodeText(Helper.joinAddress(msgs[i].getFrom()));
            } catch (UnsupportedEncodingException e) {
                from = Helper.joinAddress(msgs[i].getFrom());
            }
            try {
                replyto = MimeUtility.decodeText(Helper.joinAddress(msgs[i].getReplyTo()));
            } catch (UnsupportedEncodingException e) {
                replyto = Helper.joinAddress(msgs[i].getReplyTo());
            }
            try {
                to = MimeUtility
                        .decodeText(Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.TO)));
            } catch (UnsupportedEncodingException e) {
                to = Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.TO));
            }
            try {
                cc = MimeUtility
                        .decodeText(Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.CC)));
            } catch (UnsupportedEncodingException e) {
                cc = Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.CC));
            }
            try {
                bcc = MimeUtility
                        .decodeText(Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.BCC)));
            } catch (UnsupportedEncodingException e) {
                bcc = Helper.joinAddress(msgs[i].getRecipients(Message.RecipientType.BCC));
            }
            if (from == "")
                from = getStringResource("unknown sender");
            if (to == "")
                to = getStringResource("unknown recipient");

            /* Flags */
            sf = msgs[i].getFlags().getSystemFlags();
            String basepath = parent.getBasePath();

            for (int j = 0; j < sf.length; j++) {
                if (sf[j] == Flags.Flag.RECENT)
                    xml_message.setAttribute("recent", "true");
                if (sf[j] == Flags.Flag.SEEN)
                    xml_message.setAttribute("seen", "true");
                if (sf[j] == Flags.Flag.DELETED)
                    xml_message.setAttribute("deleted", "true");
                if (sf[j] == Flags.Flag.ANSWERED)
                    xml_message.setAttribute("answered", "true");
                if (sf[j] == Flags.Flag.DRAFT)
                    xml_message.setAttribute("draft", "true");
                if (sf[j] == Flags.Flag.FLAGGED)
                    xml_message.setAttribute("flagged", "true");
                if (sf[j] == Flags.Flag.USER)
                    xml_message.setAttribute("user", "true");
            }
            if (msgs[i] instanceof MimeMessage
                    && ((MimeMessage) msgs[i]).getContentType().toUpperCase().startsWith("MULTIPART/")) {
                xml_message.setAttribute("attachment", "true");
            }

            if (msgs[i] instanceof MimeMessage) {
                int size = ((MimeMessage) msgs[i]).getSize();
                size /= 1024;
                xml_message.setAttribute("size", (size > 0 ? size + "" : "<1") + " kB");
            }

            /* Subject */
            subject = "";
            if (msgs[i].getSubject() != null) {
                try {
                    subject = MimeUtility.decodeText(msgs[i].getSubject());
                } catch (UnsupportedEncodingException ex) {
                    subject = msgs[i].getSubject();
                    log.warn("Unsupported Encoding: " + ex.getMessage());
                }
            }
            if (subject == null || subject.equals("")) {
                subject = getStringResource("no subject");
            }

            /* Set all of what we found into the DOM */
            xml_message.setHeader("FROM", from);
            try {
                // hmm, why decode subject twice? Though it doesn't matter..
                xml_message.setHeader("SUBJECT", MimeUtility.decodeText(subject));
            } catch (UnsupportedEncodingException e) {
                xml_message.setHeader("SUBJECT", subject);
                log.warn("Unsupported Encoding: " + e.getMessage());
            }
            xml_message.setHeader("TO", to);
            xml_message.setHeader("CC", cc);
            xml_message.setHeader("BCC", bcc);
            xml_message.setHeader("REPLY-TO", replyto);

            /* Date */
            Date d = msgs[i].getSentDate();
            String ds = "";
            if (d != null) {
                ds = df.format(d);
            }
            xml_message.setHeader("DATE", ds);
        }
        long time_stop = System.currentTimeMillis();
        // try {
        // XMLCommon.writeXML(model.getRoot(),new FileOutputStream("/tmp/wmdebug"),"");
        // } catch(IOException ex) {}

        log.debug("Construction of message list took " + (time_stop - time_start)
                + " ms. Time for IMAP transfer was " + (fetch_stop - fetch_start) + " ms.");
        folder.close(false);
    } catch (NullPointerException e) {
        log.error("Failed to construct message list", e);
        throw new NoSuchFolderException(folderhash);
    } catch (MessagingException ex) {
        log.error("Failed to construct message list.  " + "For some reason, contuing anyways.", ex);
    }
}

From source file:org.wso2.carbon.appmgt.hostobjects.APIStoreHostObject.java

public static NativeArray jsFunction_getAPI(Context cx, Scriptable thisObj, Object[] args, Function funObj)
        throws ScriptException, AppManagementException {

    String providerName;//from   w w w.j a  v a 2s.  c  o  m
    String apiName;
    String version;
    String username = null;
    boolean isSubscribed = false;
    NativeArray myn = new NativeArray(0);
    if (args != null && args.length != 0) {

        providerName = AppManagerUtil.replaceEmailDomain((String) args[0]);
        apiName = (String) args[1];
        version = (String) args[2];
        if (args[3] != null) {
            username = (String) args[3];
        }
        APIIdentifier apiIdentifier = new APIIdentifier(providerName, apiName, version);
        WebApp api;
        APIConsumer apiConsumer = getAPIConsumer(thisObj);
        boolean isTenantFlowStarted = false;
        try {
            String tenantDomain = MultitenantUtils
                    .getTenantDomain(AppManagerUtil.replaceEmailDomainBack(providerName));
            if (tenantDomain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
                isTenantFlowStarted = true;
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
            }

            api = apiConsumer.getAPI(apiIdentifier);
            if (username != null) {
                //TODO @sumedha : remove hardcoded tenant Id
                isSubscribed = apiConsumer.isSubscribed(apiIdentifier, username);
            }

            if (api != null) {
                NativeObject row = new NativeObject();
                apiIdentifier = api.getId();
                row.put("name", row, apiIdentifier.getApiName());
                row.put("provider", row,
                        AppManagerUtil.replaceEmailDomainBack(apiIdentifier.getProviderName()));
                row.put("version", row, apiIdentifier.getVersion());
                row.put("description", row, api.getDescription());
                row.put("rates", row, api.getRating());
                row.put("endpoint", row, api.getUrl());
                row.put("wsdl", row, api.getWsdlUrl());
                row.put("wadl", row, api.getWadlUrl());
                DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
                dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
                String dateFormatted = dateFormat.format(api.getLastUpdated());
                row.put("updatedDate", row, dateFormatted);
                row.put("context", row, api.getContext());
                row.put("status", row, api.getStatus().getStatus());

                AppManagerConfiguration config = HostObjectComponent.getAPIManagerConfiguration();
                List<Environment> environments = config.getApiGatewayEnvironments();
                String envDetails = "";
                for (int i = 0; i < environments.size(); i++) {
                    Environment environment = environments.get(i);
                    envDetails += environment.getName() + ",";
                    envDetails += filterUrls(environment.getApiGatewayEndpoint(), api.getTransports());
                    if (i < environments.size() - 1) {
                        envDetails += "|";
                    }
                }
                //row.put("serverURL", row, config.getFirstProperty(AppMConstants.API_GATEWAY_API_ENDPOINT));
                row.put("serverURL", row, envDetails);
                NativeArray tierArr = new NativeArray(0);
                Set<Tier> tierSet = api.getAvailableTiers();
                if (tierSet != null) {
                    Iterator it = tierSet.iterator();
                    int j = 0;

                    while (it.hasNext()) {
                        NativeObject tierObj = new NativeObject();
                        Object tierObject = it.next();
                        Tier tier = (Tier) tierObject;
                        tierObj.put("tierName", tierObj, tier.getName());
                        tierObj.put("tierDisplayName", tierObj, tier.getDisplayName());
                        tierObj.put("tierDescription", tierObj,
                                tier.getDescription() != null ? tier.getDescription() : "");
                        if (tier.getTierAttributes() != null) {
                            Map<String, Object> attributes;
                            attributes = tier.getTierAttributes();
                            String attributesList = "";
                            for (Map.Entry<String, Object> attribute : attributes.entrySet()) {
                                attributesList += attribute.getKey() + "::" + attribute.getValue() + ",";

                            }
                            tierObj.put("tierAttributes", tierObj, attributesList);
                        }
                        tierArr.put(j, tierArr, tierObj);
                        j++;

                    }
                }
                row.put("tiers", row, tierArr);
                row.put("subscribed", row, isSubscribed);
                if (api.getThumbnailUrl() == null) {
                    row.put("thumbnailurl", row, "images/api-default.png");
                } else {
                    row.put("thumbnailurl", row, AppManagerUtil.prependWebContextRoot(api.getThumbnailUrl()));
                }
                row.put("bizOwner", row, api.getBusinessOwner());
                row.put("bizOwnerMail", row, api.getBusinessOwnerEmail());
                row.put("techOwner", row, api.getTechnicalOwner());
                row.put("techOwnerMail", row, api.getTechnicalOwnerEmail());
                row.put("visibility", row, api.getVisibility());
                row.put("visibleRoles", row, api.getVisibleRoles());

                Set<URITemplate> uriTemplates = api.getUriTemplates();
                List<NativeArray> uriTemplatesArr = new ArrayList<NativeArray>();
                if (uriTemplates.size() != 0) {
                    NativeArray uriTempArr = new NativeArray(uriTemplates.size());
                    Iterator i = uriTemplates.iterator();

                    while (i.hasNext()) {
                        List<String> utArr = new ArrayList<String>();
                        URITemplate ut = (URITemplate) i.next();
                        utArr.add(ut.getUriTemplate());
                        utArr.add(ut.getMethodsAsString().replaceAll("\\s", ","));
                        utArr.add(ut.getAuthTypeAsString().replaceAll("\\s", ","));
                        utArr.add(ut.getThrottlingTiersAsString().replaceAll("\\s", ","));
                        NativeArray utNArr = new NativeArray(utArr.size());
                        for (int p = 0; p < utArr.size(); p++) {
                            utNArr.put(p, utNArr, utArr.get(p));
                        }
                        uriTemplatesArr.add(utNArr);
                    }

                    for (int c = 0; c < uriTemplatesArr.size(); c++) {
                        uriTempArr.put(c, uriTempArr, uriTemplatesArr.get(c));
                    }

                    myn.put(1, myn, uriTempArr);
                }
                row.put("uriTemplates", row, uriTemplatesArr.toString());
                String apiOwner = api.getAppOwner();
                if (apiOwner == null) {
                    apiOwner = AppManagerUtil.replaceEmailDomainBack(apiIdentifier.getProviderName());
                }
                row.put("apiOwner", row, apiOwner);
                row.put("isAdvertiseOnly", row, api.isAdvertiseOnly());
                row.put("redirectURL", row, api.getRedirectURL());

                row.put("subscriptionAvailability", row, api.getSubscriptionAvailability());
                row.put("subscriptionAvailableTenants", row, api.getSubscriptionAvailableTenants());
                row.put("isDefaultVersion", row, api.isDefaultVersion());
                myn.put(0, myn, row);
            }

        } catch (AppManagementException e) {
            handleException("Error from Registry WebApp while getting get WebApp Information on " + apiName, e);

        } catch (Exception e) {
            handleException(e.getMessage(), e);
        } finally {
            if (isTenantFlowStarted) {
                PrivilegedCarbonContext.endTenantFlow();
            }
        }
    }
    return myn;
}

From source file:com.clustercontrol.jobmanagement.factory.SelectJob.java

/**
 * ???????//from   ww w . j a  v  a2  s  .  c  o  m
 *
 * @param sessionId ID
 * @param jobId ID
 * @param jobunitId ID
 * @param destFacilityId ?ID
 * @param destFacilityName ???
 * @param checksum ?
 * @param locale 
 * @return 
 * @throws JobInfoNotFound
 */
private String getFileJobDetailMessage(String sessionId, String jobunitId, String jobId, String destFacilityId,
        String destFacilityName, boolean checksum, Locale locale) throws JobInfoNotFound {

    final String START = "_START";
    final String END = "_END";
    final String FILE = "_FILE";
    final String RTN = "\n";

    StringBuilder message = new StringBuilder();

    if (sessionId == null || sessionId.length() == 0 || jobId == null || jobId.length() == 0) {
        return message.toString();
    }

    // UTILIUPDT_S??
    if (CreateHulftJob.isHulftMode()) {
        try {
            JobSessionJobEntity job = QueryUtil.getJobSessionJobPK(sessionId, jobunitId, jobId);
            JobSessionJobEntity jobUtliupdtS = QueryUtil.getJobSessionJobPK(sessionId, jobunitId,
                    job.getParentJobId() + CreateHulftJob.UTILIUPDT_S);
            if (jobUtliupdtS.getEndDate() != null) {
                if (jobUtliupdtS.getEndStatus() == null
                        || jobUtliupdtS.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : jobUtliupdtS.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                }
            }
        } catch (JobInfoNotFound e) {
            m_log.debug("getFileJobDetailMessage() : " + e.getMessage());
        } catch (InvalidRole e) {
            m_log.info("getFileJobDetailMessage() : " + e.getMessage());
        }
    }

    //ID?
    Collection<JobSessionJobEntity> collection = QueryUtil.getChildJobSessionJobOrderByStartDate(sessionId,
            jobunitId, jobId);
    if (collection == null) {
        JobInfoNotFound je = new JobInfoNotFound("JobSessionJobEntity.findByStartDate"
                + ", [sessionId, parentJobId] = " + "[" + sessionId + ", " + jobId + "]");
        m_log.info("getFileJobDetailMessage() : " + je.getClass().getSimpleName() + ", " + je.getMessage());
        je.setSessionId(sessionId);
        je.setParentJobId(jobId);
        throw je;
    }

    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, locale);
    dateFormat.setTimeZone(HinemosTime.getTimeZone());
    HashMap<String, String> jobIdMap = new HashMap<String, String>();

    for (JobSessionJobEntity childSessionJob : collection) {
        JobInfoEntity childJob = childSessionJob.getJobInfoEntity();
        String childJobId = childSessionJob.getId().getJobId();

        if (childJobId.indexOf(CreateFileJob.GET_KEY) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.GET_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (childSessionJob.getEndStatus() == null
                            || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL)) {
                for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                    String nodeMessage = node.getMessage();
                    if (nodeMessage != null && nodeMessage.length() > 0) {
                        message.append(nodeMessage);
                        message.append(RTN);
                    }
                }
                jobIdMap.put(fileJobId, END);
            }

        } else if (childJobId.indexOf(CreateFileJob.ADD_KEY) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.ADD_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateFileJob.GET_CHECKSUM) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.GET_CHECKSUM, "");
            jobIdMap.put(fileJobId + FILE, childJob.getArgument());
            //????
            if (childSessionJob.getStartDate() != null) {
                String dateString = dateFormat.format(childSessionJob.getStartDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                message.append(MessageConstant.MESSAGE_STARTED_TO_TRANSFER_FILE.getMessage(args));
                message.append(RTN);
                jobIdMap.put(fileJobId, START);
            }
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    String dateString = dateFormat.format(childSessionJob.getEndDate());
                    String file = childJob.getArgument();
                    String[] args = { dateString, file, destFacilityName };
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateFileJob.FORWARD) != -1) {
            //"_FORWARD"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.FORWARD, "");
            //????
            if (childSessionJob.getStartDate() != null && !checksum) {
                String dateString = dateFormat.format(childSessionJob.getStartDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                message.append(MessageConstant.MESSAGE_STARTED_TO_TRANSFER_FILE.getMessage(args));
                message.append(RTN);
                jobIdMap.put(fileJobId, START);
            }
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                String dateString = dateFormat.format(childSessionJob.getEndDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                if (childSessionJob.getEndStatus() != null
                        && childSessionJob.getEndStatus() == EndStatusConstant.TYPE_NORMAL) {
                    if (!checksum) {
                        message.append(MessageConstant.MESSAGE_FINISHED_TRANSFERRING_FILE.getMessage(args));
                        message.append(RTN);
                        jobIdMap.put(fileJobId, END);
                    }
                } else {
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        m_log.debug(node.getId().getJobId());
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }
            if (!checksum) {
                jobIdMap.remove(fileJobId);
                jobIdMap.remove(fileJobId + FILE);
            }

        } else if (childJobId.indexOf(CreateFileJob.CHECK_CHECKSUM) != -1) {
            //"_CHECK_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.CHECK_CHECKSUM, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                String dateString = dateFormat.format(childSessionJob.getEndDate());
                String file = jobIdMap.get(fileJobId + FILE);
                String[] args = { dateString, file, destFacilityName };
                if (childSessionJob.getEndStatus() != null
                        && childSessionJob.getEndStatus() == EndStatusConstant.TYPE_NORMAL) {
                    message.append(MessageConstant.MESSAGE_FINISHED_TRANSFERRING_FILE.getMessage(args));
                    message.append(RTN);
                } else {
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        m_log.debug(node.getId().getJobId());
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }
            jobIdMap.remove(fileJobId);
            jobIdMap.remove(fileJobId + FILE);

        } else if (childJobId.indexOf(CreateFileJob.DEL_KEY) != -1) {
            //"_DEL_KEY"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.DEL_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_R) != -1) {
            //"_UTILIUPDT_R"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_R, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_H_SND) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_H_SND, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_H_RCV) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_H_RCV, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTLSEND) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTLSEND, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.HULOPLCMD) != -1) {
            //"_HULOPLCMD"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.HULOPLCMD, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                // HULOPLCMD??????????????
                for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                    String nodeMessage = node.getMessage();
                    if (nodeMessage != null && nodeMessage.length() > 0) {
                        message.append(nodeMessage);
                        message.append(RTN);
                    }
                }
                jobIdMap.put(fileJobId, END);
            }
        }

        m_log.debug("getFileJobDetailMessage() : jobid=" + childJobId + ", message=" + message);
    }

    if (message.length() > 0) {
        message.setLength(message.length() - 1);
    }

    return message.toString();
}

From source file:de.escidoc.core.test.EscidocTestBase.java

/**
 * Get the current time as timestamp. The date format is yyyy-MM-dd'T'HH:mm:ss.SSSZ.
 * //from   w w  w  .j av a 2s.c o  m
 * @return The current time as timestamp.
 */
public static String getNowAsTimestamp() {

    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN);
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    return dateFormat.format(new Date()).replaceAll("\\+0000", "Z").replaceAll("([+-][0-9]{2}):([0-9]{2})",
            "$1$2");
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

/**
 * Returns date in specified format/*w  ww.  jav a2  s  . c o m*/
 * @param date Date object
 * @return Date in specified format
 */
String formatDate(Date date) {
    if (date == null)
        return null;
    Locale userLocale = DateHelper.getPreferredLocale(null);
    TimeZone userZone = DateHelper.getPreferredTimeZone(null);
    DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, userLocale);
    format.setTimeZone(userZone);

    return removeSeconds(format.format(date));
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

private void showThreadPreviewDialog(final int position) {
    final List<PresentationItemModel> items = new ArrayList<>();
    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);/*from   w w w. java2 s .  c o  m*/
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    tmpDlg.show();
    Runnable next = new Runnable() {
        @Override
        public void run() {
            final int dlgWidth = tmpV.getWidth();
            tmpDlg.hide();
            tmpDlg.cancel();
            final Dialog dialog = new Dialog(activity);

            if (presentationModel.source != null && presentationModel.source.threads != null
                    && presentationModel.source.threads.length > position
                    && presentationModel.source.threads[position].posts != null
                    && presentationModel.source.threads[position].posts.length > 0) {

                final String threadNumber = presentationModel.source.threads[position].posts[0].number;

                ClickableURLSpan.URLSpanClickListener spanClickListener = new ClickableURLSpan.URLSpanClickListener() {
                    @Override
                    public void onClick(View v, ClickableURLSpan span, String url, String referer) {
                        if (url.startsWith("#")) {
                            try {
                                UrlPageModel threadPageModel = new UrlPageModel();
                                threadPageModel.chanName = chan.getChanName();
                                threadPageModel.type = UrlPageModel.TYPE_THREADPAGE;
                                threadPageModel.boardName = tabModel.pageModel.boardName;
                                threadPageModel.threadNumber = threadNumber;
                                url = chan.buildUrl(threadPageModel) + url;
                                dialog.dismiss();
                                UrlHandler.open(chan.fixRelativeUrl(url), activity);
                            } catch (Exception e) {
                                Logger.e(TAG, e);
                            }
                        } else {
                            dialog.dismiss();
                            UrlHandler.open(chan.fixRelativeUrl(url), activity);
                        }
                    }
                };

                AndroidDateFormat.initPattern();
                String datePattern = AndroidDateFormat.getPattern();
                DateFormat dateFormat = datePattern == null
                        ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                        : new SimpleDateFormat(datePattern, Locale.US);
                dateFormat.setTimeZone(settings.isLocalTime() ? TimeZone.getDefault()
                        : TimeZone.getTimeZone(presentationModel.source.boardModel.timeZoneId));

                int postsCount = presentationModel.source.threads[position].postsCount;
                boolean showIndex = presentationModel.source.threads[position].posts.length <= postsCount;
                int curPostIndex = postsCount - presentationModel.source.threads[position].posts.length + 1;

                boolean openSpoilers = settings.openSpoilers();

                for (int i = 0; i < presentationModel.source.threads[position].posts.length; ++i) {
                    PresentationItemModel model = new PresentationItemModel(
                            presentationModel.source.threads[position].posts[i], chan.getChanName(),
                            presentationModel.source.pageModel.boardName,
                            presentationModel.source.pageModel.threadNumber, dateFormat, spanClickListener,
                            imageGetter, ThemeUtils.ThemeColors.getInstance(activity.getTheme()), openSpoilers,
                            floatingModels, null);
                    model.buildSpannedHeader(showIndex ? (i == 0 ? 1 : ++curPostIndex) : -1,
                            presentationModel.source.boardModel.bumpLimit,
                            presentationModel.source.boardModel.defaultUserName, null, false);
                    items.add(model);
                }
            } else {
                items.add(presentationModel.presentationList.get(position));
            }
            ListView dlgList = new ListView(activity);
            dlgList.setAdapter(new ArrayAdapter<PresentationItemModel>(activity, 0, items) {
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    View view = adapter.getView(position, convertView, parent, dlgWidth, getItem(position));
                    view.setBackgroundColor(bgColor);
                    return view;
                }
            });
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(dlgList);
            dialog.show();
            dialogs.add(dialog);
        }
    };
    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}