Example usage for java.util TreeSet isEmpty

List of usage examples for java.util TreeSet isEmpty

Introduction

In this page you can find the example usage for java.util TreeSet isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.jefftharris.passwdsafe.NotificationMgr.java

/**
 * Handle the expiration entries for a URI in the database. Return whether
 * the URI exists./* www . jav  a2 s. c  o m*/
 */
private boolean loadUri(final long uriId, final Uri uri, final HashSet<Long> expiredUris, final long expiration,
        final LongReference nextExpiration, final SQLiteDatabase db) throws SQLException {
    PasswdFileUri.Creator creator = new PasswdFileUri.Creator(uri, itsCtx);
    PasswdFileUri passwdUri = creator.finishCreate();
    if ((passwdUri == null) || !passwdUri.exists()) {
        PasswdSafeUtil.dbginfo(TAG, "Notif file doesn't exist: %s", uri);
        return false;
    }

    itsNotifUris.add(uri);
    PasswdSafeUtil.dbginfo(TAG, "Load %s", uri);

    TreeSet<ExpiryEntry> expired = loadUriEntries(uriId, expiration, nextExpiration, db);

    if (expired.isEmpty()) {
        return true;
    }

    expiredUris.add(uriId);
    UriNotifInfo info = itsUriNotifs.get(uriId);
    if (info == null) {
        info = new UriNotifInfo(itsNextNotifId++);
        itsUriNotifs.put(uriId, info);
    }

    // Skip the notification if the entries are the same
    if (info.getEntries().equals(expired)) {
        PasswdSafeUtil.dbginfo(TAG, "No expiry changes");
        return true;
    }

    info.setEntries(expired);
    int numExpired = info.getEntries().size();
    ArrayList<String> strs = new ArrayList<>(numExpired);
    for (ExpiryEntry entry : info.getEntries()) {
        strs.add(entry.toString(itsCtx));
    }

    String record = null;
    if (numExpired == 1) {
        ExpiryEntry entry = info.getEntries().first();
        record = entry.itsUuid;
    }

    PendingIntent intent = PendingIntent.getActivity(itsCtx, 0, PasswdSafeUtil.createOpenIntent(uri, record),
            PendingIntent.FLAG_UPDATE_CURRENT);

    String title = itsCtx.getResources().getQuantityString(R.plurals.expiring_passwords, numExpired,
            numExpired);
    GuiUtils.showNotification(itsNotifyMgr, itsCtx, R.drawable.ic_stat_app,
            itsCtx.getString(R.string.expiring_password), title, R.mipmap.ic_launcher_passwdsafe,
            passwdUri.getIdentifier(itsCtx, false), strs, intent, info.getNotifId(), false);
    return true;
}

From source file:net.tjado.passwdsafe.NotificationMgr.java

/**
 * Handle the expiration entries for a URI in the database. Return whether
 * the URI exists./* w w w  .j av  a  2  s . co  m*/
 */
private boolean loadUri(final long uriId, final Uri uri, final HashSet<Long> expiredUris, final long expiration,
        final LongReference nextExpiration, final SQLiteDatabase db) throws SQLException {
    PasswdFileUri.Creator creator = new PasswdFileUri.Creator(uri, itsCtx);
    PasswdFileUri passwdUri = creator.finishCreate();
    if ((passwdUri == null) || !passwdUri.exists()) {
        PasswdSafeUtil.dbginfo(TAG, "Notif file doesn't exist: %s", uri);
        return false;
    }

    itsNotifUris.add(uri);
    PasswdSafeUtil.dbginfo(TAG, "Load %s", uri);

    TreeSet<ExpiryEntry> expired = loadUriEntries(uriId, expiration, nextExpiration, db);

    if (expired.isEmpty()) {
        return true;
    }

    expiredUris.add(uriId);
    UriNotifInfo info = itsUriNotifs.get(uriId);
    if (info == null) {
        info = new UriNotifInfo(itsNextNotifId++);
        itsUriNotifs.put(uriId, info);
    }

    // Skip the notification if the entries are the same
    if (info.getEntries().equals(expired)) {
        PasswdSafeUtil.dbginfo(TAG, "No expiry changes");
        return true;
    }

    info.setEntries(expired);
    int numExpired = info.getEntries().size();
    ArrayList<String> strs = new ArrayList<>(numExpired);
    for (ExpiryEntry entry : info.getEntries()) {
        strs.add(entry.toString(itsCtx));
    }

    String record = null;
    if (numExpired == 1) {
        ExpiryEntry entry = info.getEntries().first();
        record = entry.itsUuid;
    }

    PendingIntent intent = PendingIntent.getActivity(itsCtx, 0, PasswdSafeUtil.createOpenIntent(uri, record),
            PendingIntent.FLAG_UPDATE_CURRENT);

    String title = itsCtx.getResources().getQuantityString(R.plurals.expiring_passwords, numExpired,
            numExpired);
    GuiUtils.showNotification(itsNotifyMgr, itsCtx, R.drawable.ic_stat_app,
            itsCtx.getString(R.string.expiring_password), title, R.mipmap.ic_launcher_passwdsafe,
            passwdUri.getIdentifier(itsCtx, false), strs, intent, info.getNotifId(), null, false);
    return true;
}

From source file:org.apache.kylin.storage.hbase.HBaseResourceStore.java

@Override
protected NavigableSet<String> listResourcesImpl(String folderPath) throws IOException {
    final TreeSet<String> result = new TreeSet<>();

    visitFolder(folderPath, new KeyOnlyFilter(), new FolderVisitor() {
        @Override/* ww  w . j  a  v a2s. co m*/
        public void visit(String childPath, String fullPath, Result hbaseResult) {
            result.add(childPath);
        }
    });
    // return null to indicate not a folder
    return result.isEmpty() ? null : result;
}

From source file:org.parosproxy.paros.network.HttpRequestHeader.java

public void setCookieParams(TreeSet<HtmlParameter> cookieParams) {
    if (cookieParams.isEmpty()) {
        setHeader(HttpHeader.COOKIE, null);
    }/*from   w w w .  j  ava 2s. c  o  m*/

    StringBuilder sbData = new StringBuilder();

    for (HtmlParameter parameter : cookieParams) {
        if (parameter.getType() != HtmlParameter.Type.cookie) {
            continue;
        }

        sbData.append(parameter.getName());
        sbData.append('=');
        sbData.append(parameter.getValue());
        sbData.append("; ");
    }

    if (sbData.length() <= 3) {
        setHeader(HttpHeader.COOKIE, null);
        return;
    }

    final String data = sbData.substring(0, sbData.length() - 2);
    setHeader(HttpHeader.COOKIE, data);
}

From source file:edu.fullerton.ldvw.ImageHistory.java

/**
 * Add a table of buttons/links and info to control display and deletion
 *
 * @param imgCnt total number of records in selection
 *///  w  w  w  .j  av  a 2 s. c o  m
private PageItemList getNavBar(int imgCnt, boolean isBottom, String frmName)
        throws WebUtilException, LdvTableException, SQLException {
    PageItemList ret = new PageItemList();
    PageTable navBar = new PageTable();
    PageTableRow cmds = new PageTableRow();

    // add next/prev buttons if applicable
    PageFormButton prevBtn = new PageFormButton("submitAct", "<", "Prev");
    prevBtn.setEnabled(strt > 0);
    cmds.add(prevBtn);

    String botSuffix = isBottom ? "2" : "";

    int curPage = strt / cnt + 1;
    int nPage = (imgCnt + cnt - 1) / cnt;
    PageItemList pageSel = new PageItemList();
    pageSel.add("Page: ");
    PageFormText pageNum = new PageFormText("pageNum" + botSuffix, String.format("%1$,d", curPage));
    pageNum.setSize(3);
    pageNum.setMaxLen(6);
    pageNum.addEvent("onchange", "historySubmit('Go" + botSuffix + "', this);");
    pageSel.add(pageNum);
    pageSel.add(String.format(" of %d ", nPage));
    cmds.add(pageSel);

    PageFormButton nextBtn = new PageFormButton("submitAct", ">", "Next");
    nextBtn.setEnabled(curPage < nPage);
    cmds.add(nextBtn);

    int stop = Math.min(strt + cnt, imgCnt);
    String showing = String.format("Showing %1$d-%2$d for:", strt + 1, stop);
    cmds.add(showing);

    // add selection by user
    String cn = vuser.getCn();

    TreeMap<String, Integer> ucounts = imgTbl.getCountByUser();
    String[] usrs = new String[ucounts.size() + 1];
    String sel = "All";
    usrs[0] = "All";
    int i = 1;
    for (Map.Entry<String, Integer> entry : ucounts.entrySet()) {
        String u = entry.getKey();
        Integer cnts = entry.getValue();
        String opt = String.format("%1$s (%2$d)", u, cnts);
        if (userWanted.equalsIgnoreCase(u)) {
            sel = opt;
        }
        usrs[i] = opt;
        i++;
    }
    if (!isBottom) {
        // allow them to select another user (or all)
        PageFormSelect usrSel = new PageFormSelect("usrSel", usrs);
        usrSel.setSelected(sel);
        usrSel.addEvent("onchange", "this.form.submit()");
        PageItemList owner = new PageItemList();
        owner.add(new PageItemString("Owner:&nbsp;", false));
        owner.add(usrSel);
        cmds.add(owner);

        // Group selector
        TreeSet<String> groups = imgGrpTbl.getGroups(userWanted);
        if (!groups.isEmpty()) {
            PageItemList grpPIL = new PageItemList();
            grpPIL.add(new PageItemString("Group:&nbsp;", false));
            groups.add("All");
            PageFormSelect grpSel = new PageFormSelect("group");
            grpSel.add(groups);
            String curGroup = request.getParameter("group");
            if (curGroup != null && !curGroup.isEmpty() && groups.contains(curGroup)) {
                grpSel.setSelected(curGroup);
            } else {
                grpSel.setSelected("All");
            }
            grpSel.addEvent("onchange", "document." + frmName + ".submit()");
            grpPIL.add(grpSel);
            cmds.add(grpPIL);
        }
    }
    cmds.setClassAll("noborder");
    navBar.addRow(cmds);
    ret.add(navBar);

    if (!isBottom) {
        // New table because this one has fewer columns and we want to hide it by default
        navBar = new PageTable();
        navBar.setClassName("hidable");
        navBar.addStyle("display", "none");

        // allow them to change image size
        PageTableRow cmd2 = new PageTableRow();
        String[] sizes = { "original", "small", "med" };
        PageFormSelect sizeSel = new PageFormSelect("size", sizes);
        String curSize = request.getParameter("size");
        if (curSize != null && !curSize.isEmpty() && ArrayUtils.contains(sizes, curSize)) {
            sizeSel.setSelected(curSize);
        }
        sizeSel.addEvent("onchange", "document." + frmName + ".submit()");
        PageItemString lbl;
        lbl = new PageItemString("Size:&nbsp;", false);
        lbl.setAlign(PageItem.Alignment.RIGHT);
        cmd2.add(lbl);
        PageTableColumn col;
        col = new PageTableColumn(sizeSel);
        cmd2.add(col);
        cmd2.add();
        cmd2.add();
        cmd2.setClassAll("noborder");
        navBar.addRow(cmd2);

        cmd2 = new PageTableRow();
        lbl = new PageItemString("Selections:&nbsp;", false);
        lbl.setAlign(PageItem.Alignment.RIGHT);
        cmd2.add(lbl);

        PageFormButton selAll = new PageFormButton("selAll", "Select all", "selall");
        selAll.setType("button");
        selAll.addEvent("onclick", "setChkBoxByClass('selBox',true)");
        cmd2.add(selAll);

        PageFormButton clrAll = new PageFormButton("selAll", "Clear all", "clrall");
        clrAll.setType("button");
        clrAll.addEvent("onclick", "setChkBoxByClass('selBox', false)");
        cmd2.add(clrAll);
        cmd2.add();
        cmd2.setClassAll("noborder");
        navBar.addRow(cmd2);

        if (userWanted.equalsIgnoreCase(vuser.getCn()) || vuser.isAdmin()) {
            cmd2 = new PageTableRow();
            lbl = new PageItemString("Delete images:&nbsp;", false);
            lbl.setAlign(PageItem.Alignment.RIGHT);
            cmd2.add(lbl);

            col = new PageTableColumn(new PageFormSubmit("submitAct", "Delete Selected"));
            cmd2.add(col);
            cmd2.add();
            cmd2.add();
            cmd2.setClassAll("noborder");
            navBar.addRow(cmd2);
        }

        PageTableRow grpRow = new PageTableRow();
        lbl = new PageItemString("My groups:&nbsp;", false);
        lbl.setAlign(PageItem.Alignment.RIGHT);
        grpRow.add(lbl);

        TreeSet<String> myGroup = imgGrpTbl.getGroups(curUser);
        if (!myGroup.contains("Favorites")) {
            myGroup.add("Favorites");
        }
        myGroup.remove("Last result");
        PageFormSelect grpSel = new PageFormSelect("op_group");
        grpSel.add(myGroup);
        String curGroup = request.getParameter("groupSel");
        if (curGroup != null && !curGroup.isEmpty() && myGroup.contains(curGroup)) {
            grpSel.setSelected(curGroup);
        } else {
            grpSel.setSelected("Favorites");
        }
        grpRow.add(grpSel);

        grpRow.add(new PageFormSubmit("submitAct", "Add to grp"));
        grpRow.add(new PageFormSubmit("submitAct", "Del from grp"));
        grpRow.setClassAll("noborder");
        navBar.addRow(grpRow);
        grpRow = new PageTableRow();
        lbl = new PageItemString("New Group:&nbsp;", false);
        lbl.setAlign(PageItem.Alignment.RIGHT);
        grpRow.add(lbl);
        PageFormText grpNameTxt = new PageFormText("newGrpName", "<new group name>");
        grpNameTxt.addEvent("onfocus", "if(this.value == '<new group name>'){ this.value = ''; }");
        grpNameTxt.addEvent("onblur", "if(this.value == ''){ this.value = '<new group name>'; }");
        grpRow.add(grpNameTxt);
        PageFormSubmit newGrpBtn = new PageFormSubmit("submitAct", "New grp");
        grpRow.add(newGrpBtn);
        grpRow.add();
        grpRow.setClassAll("noborder");
        navBar.addRow(grpRow);
        ret.add(navBar);

        PageItemString optBtn = new PageItemString("+More options");
        optBtn.addEvent("onclick", "showByClass('hidable',this)");
        optBtn.setClassName("showCmd");
        ret.addBlankLines(1);
        ret.add(optBtn);
    }
    vpage.includeJS("showByClass.js");
    return ret;
}

From source file:org.opendatakit.security.server.SecurityServiceUtil.java

/**
 * Method to enforce an access configuration constraining only registered users, authenticated
 * users and anonymous access./*w ww  .j  a  v  a 2s  . c  om*/
 * 
 * Add additional checks of the incoming parameters and patch things up if the incoming list of
 * users omits the super-user.
 * 
 * @param users
 * @param anonGrants
 * @param allGroups
 * @param cc
 * @throws DatastoreFailureException
 * @throws AccessDeniedException
 */
public static final void setStandardSiteAccessConfiguration(ArrayList<UserSecurityInfo> users,
        ArrayList<GrantedAuthorityName> allGroups, CallingContext cc)
        throws DatastoreFailureException, AccessDeniedException {

    // remove anonymousUser from the set of users and collect its
    // permissions (anonGrantStrings) which will be placed in
    // the granted authority hierarchy table.
    List<String> anonGrantStrings = new ArrayList<String>();
    {
        UserSecurityInfo anonUser = null;
        for (UserSecurityInfo i : users) {
            if (i.getType() == UserType.ANONYMOUS) {
                anonUser = i;
                // clean up grants for anonymousUser --
                // ignore anonAuth (the grant under which we will place things)
                // and forbid Site Admin
                for (GrantedAuthorityName a : i.getAssignedUserGroups()) {
                    if (anonAuth.getAuthority().equals(a.name()))
                        continue; // avoid circularity...
                    // only allow ROLE_ATTACHMENT_VIEWER and GROUP_ assignments.
                    if (!a.name().startsWith(GrantedAuthorityName.GROUP_PREFIX)) {
                        continue;
                    }
                    // do not allow Site Admin assignments for Anonymous --
                    // or Tables super-user or Tables Administrator.
                    // those all give access to the full set of users on the system
                    // and giving that information to Anonymous is a security
                    // risk.
                    if (GrantedAuthorityName.GROUP_SITE_ADMINS.equals(a)
                            || GrantedAuthorityName.GROUP_ADMINISTER_TABLES.equals(a)
                            || GrantedAuthorityName.GROUP_SUPER_USER_TABLES.equals(a)) {
                        continue;
                    }
                    anonGrantStrings.add(a.name());
                }
                break;
            }
        }
        if (anonUser != null) {
            users.remove(anonUser);
        }
    }

    // scan through the users and remove any entries under assigned user groups
    // that do not begin with GROUP_.
    //
    // Additionally, if the user is an e-mail, remove the GROUP_DATA_COLLECTORS
    // permission since ODK Collect does not support oauth2 authentication.
    {
        TreeSet<GrantedAuthorityName> toRemove = new TreeSet<GrantedAuthorityName>();
        for (UserSecurityInfo i : users) {
            // only working with registered users
            if (i.getType() != UserType.REGISTERED) {
                continue;
            }
            // get the list of assigned groups
            // -- this is not a copy -- we can directly manipulate this.
            TreeSet<GrantedAuthorityName> assignedGroups = i.getAssignedUserGroups();

            // scan the set of assigned groups and remove any that don't begin with GROUP_
            toRemove.clear();
            for (GrantedAuthorityName name : assignedGroups) {
                if (!name.name().startsWith(GrantedAuthorityName.GROUP_PREFIX)) {
                    toRemove.add(name);
                }
            }
            if (!toRemove.isEmpty()) {
                assignedGroups.removeAll(toRemove);
            }
            // for e-mail accounts, remove the Data Collector permission since ODK Collect
            // does not support an oauth2 authentication mechanism.
            if (i.getEmail() != null) {
                assignedGroups.remove(GrantedAuthorityName.GROUP_DATA_COLLECTORS);
            }
        }
    }

    // find the entry(entries) for the designated super-user(s)
    String superUserUsername = cc.getUserService().getSuperUserUsername();
    int expectedSize = ((superUserUsername != null) ? 1 : 0);
    ArrayList<UserSecurityInfo> superUsers = new ArrayList<UserSecurityInfo>();
    for (UserSecurityInfo i : users) {
        if (i.getType() == UserType.REGISTERED) {
            if (i.getUsername() != null && superUserUsername != null
                    && i.getUsername().equals(superUserUsername)) {
                superUsers.add(i);
            }
        }
    }

    if (superUsers.size() != expectedSize) {
        // we are missing one or both super-users.
        // remove any we have and recreate them from scratch.
        users.removeAll(superUsers);
        superUsers.clear();

        // Synthesize a UserSecurityInfo object for the super-user(s)
        // and add it(them) to the list.

        try {
            List<RegisteredUsersTable> tList = RegisteredUsersTable.assertSuperUsers(cc);

            for (RegisteredUsersTable t : tList) {
                UserSecurityInfo i = new UserSecurityInfo(t.getUsername(), t.getFullName(), t.getEmail(),
                        UserSecurityInfo.UserType.REGISTERED);
                superUsers.add(i);
                users.add(i);
            }

        } catch (ODKDatastoreException e) {
            e.printStackTrace();
            throw new DatastoreFailureException("Incomplete update");
        }
    }

    // reset super-user privileges to have (just) site admin privileges
    // even if caller attempts to change, add, or remove them.
    for (UserSecurityInfo i : superUsers) {
        TreeSet<GrantedAuthorityName> grants = new TreeSet<GrantedAuthorityName>();
        grants.add(GrantedAuthorityName.GROUP_SITE_ADMINS);
        grants.add(GrantedAuthorityName.ROLE_SITE_ACCESS_ADMIN);
        // override whatever the user gave us.
        i.setAssignedUserGroups(grants);
    }

    try {
        // enforce our fixed set of groups and their inclusion hierarchy.
        // this is generally a no-op during normal operations.
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(siteAuth,
                SecurityServiceUtil.siteAdministratorGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(administerTablesAuth,
                SecurityServiceUtil.administerTablesGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(superUserTablesAuth,
                SecurityServiceUtil.superUserTablesGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(synchronizeTablesAuth,
                SecurityServiceUtil.synchronizeTablesGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(dataOwnerAuth,
                SecurityServiceUtil.dataOwnerGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(dataViewerAuth,
                SecurityServiceUtil.dataViewerGrants, cc);
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(dataCollectorAuth,
                SecurityServiceUtil.dataCollectorGrants, cc);

        // place the anonymous user's permissions in the granted authority table.
        GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(anonAuth, anonGrantStrings, cc);

        // get all granted authority names
        TreeSet<String> authorities = GrantedAuthorityHierarchyTable
                .getAllPermissionsAssignableGrantedAuthorities(cc.getDatastore(), cc.getCurrentUser());
        // remove the groups that have structure (i.e., those defined above).
        authorities.remove(siteAuth.getAuthority());
        authorities.remove(administerTablesAuth.getAuthority());
        authorities.remove(superUserTablesAuth.getAuthority());
        authorities.remove(synchronizeTablesAuth.getAuthority());
        authorities.remove(dataOwnerAuth.getAuthority());
        authorities.remove(dataViewerAuth.getAuthority());
        authorities.remove(dataCollectorAuth.getAuthority());
        authorities.remove(anonAuth.getAuthority());

        // delete all hierarchy structures under anything else.
        // i.e., if somehow USER_IS_REGISTERED had been granted GROUP_FORM_MANAGER
        // then this loop would leave USER_IS_REGISTERED without any grants.
        // (it repairs the database to conform to our privilege hierarchy expectations).
        List<String> empty = Collections.emptyList();
        for (String s : authorities) {
            GrantedAuthorityHierarchyTable.assertGrantedAuthorityHierarchy(new SimpleGrantedAuthority(s), empty,
                    cc);
        }

        // declare all the users (and remove users that are not in this set)
        Map<UserSecurityInfo, String> pkMap = setUsers(users, cc);

        // now, for each GROUP_..., update the user granted authority
        // table with the users that have that GROUP_... assignment.
        setUsersOfGrantedAuthority(pkMap, siteAuth, cc);
        setUsersOfGrantedAuthority(pkMap, administerTablesAuth, cc);
        setUsersOfGrantedAuthority(pkMap, superUserTablesAuth, cc);
        setUsersOfGrantedAuthority(pkMap, synchronizeTablesAuth, cc);
        setUsersOfGrantedAuthority(pkMap, dataOwnerAuth, cc);
        setUsersOfGrantedAuthority(pkMap, dataViewerAuth, cc);
        setUsersOfGrantedAuthority(pkMap, dataCollectorAuth, cc);
        // all super-users would already have their site admin role and
        // we leave that unchanged. The key is to ensure that the
        // super users are in the users list so they don't get
        // accidentally removed and that they have siteAuth group
        // membership. I.e., we don't need to manage ROLE_SITE_ACCESS_ADMIN
        // here. it is done elsewhere.

    } catch (ODKDatastoreException e) {
        e.printStackTrace();
        throw new DatastoreFailureException("Incomplete update");
    } finally {
        Datastore ds = cc.getDatastore();
        User user = cc.getCurrentUser();
        try {
            SecurityRevisionsTable.setLastRegisteredUsersRevisionDate(ds, user);
        } catch (ODKDatastoreException e) {
            // if it fails, use RELOAD_INTERVAL to force reload.
            e.printStackTrace();
        }
        try {
            SecurityRevisionsTable.setLastRoleHierarchyRevisionDate(ds, user);
        } catch (ODKDatastoreException e) {
            // if it fails, use RELOAD_INTERVAL to force reload.
            e.printStackTrace();
        }
    }
}

From source file:org.parosproxy.paros.network.HttpRequestHeader.java

public void setGetParams(TreeSet<HtmlParameter> getParams) {
    if (mUri == null) {
        return;/*ww  w. j a va2s. c  om*/
    }

    if (getParams.isEmpty()) {
        try {
            mUri.setQuery("");

        } catch (URIException e) {
            log.error(e.getMessage(), e);
        }

        return;
    }

    StringBuilder sbQuery = new StringBuilder();
    for (HtmlParameter parameter : getParams) {
        if (parameter.getType() != HtmlParameter.Type.url) {
            continue;
        }

        sbQuery.append(parameter.getName());
        sbQuery.append('=');
        sbQuery.append(parameter.getValue());
        sbQuery.append('&');
    }

    if (sbQuery.length() <= 2) {
        try {
            mUri.setQuery("");

        } catch (URIException e) {
            log.error(e.getMessage(), e);
        }

        return;
    }

    String query = sbQuery.substring(0, sbQuery.length() - 1);

    try {
        //The previous behaviour was escaping the query,
        //so it is maintained with the use of setQuery.
        mUri.setQuery(query);

    } catch (URIException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:net.firejack.platform.generate.tools.Render.java

/**
 * @param params//  ww w. j a v a 2 s . com
 * @return
 */
public String renderParams(TreeSet<Param> params) {
    if (params == null || params.isEmpty())
        return "";
    StringBuilder builder = new StringBuilder();

    int i = 0;
    for (Param param : params) {
        builder.append(renderType(param));
        builder.append(" ").append(param.getName());
        if (i < params.size() - 1) {
            builder.append(", ");
        }
        i++;
    }
    return builder.toString();
}

From source file:net.firejack.platform.generate.tools.Render.java

/**
 * @param params/*w w w . j  a v  a  2  s .c  o m*/
 * @return
 */
public String renderServiceParams(TreeSet<ServiceParam> params) {
    if (params == null || params.isEmpty())
        return "";
    StringBuilder builder = new StringBuilder();

    int i = 0;
    for (ServiceParam param : params) {
        builder.append(renderType(param));
        builder.append(" ").append(param.getName());
        if (i < params.size() - 1) {
            builder.append(", ");
        }
        i++;
    }
    return builder.toString();
}

From source file:net.firejack.platform.generate.tools.Render.java

public String renderEndpointArguments(TreeSet<ServiceParam> params) {
    if (params == null || params.isEmpty())
        return "";
    StringBuilder builder = new StringBuilder();

    int i = 0;/*w  w w  . j a  v  a  2 s.  c o m*/
    for (ServiceParam param : params) {
        builder.append(" ").append(param.getName());
        if (param.getLocation() == null) {
            builder.append(".getData()");
        }
        if (i < params.size() - 1) {
            builder.append(", ");
        }
        i++;
    }
    return builder.toString();
}