Example usage for java.util HashMap toString

List of usage examples for java.util HashMap toString

Introduction

In this page you can find the example usage for java.util HashMap toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.codarama.haxsync.services.ContactsSyncAdapterService.java

@SuppressWarnings("unused")
private static void performSync(Context context, Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) throws OperationCanceledException {
    SharedPreferences prefs = context.getSharedPreferences(context.getPackageName() + "_preferences",
            MODE_MULTI_PROCESS);//w  w  w . ja va2  s.  c  om

    mContentResolver = context.getContentResolver();

    FacebookUtil.refreshPermissions(context);

    //TODO: Clean up stuff that isn't needed anymore since Graph API
    boolean cropPhotos = true;
    boolean sync = prefs.getBoolean("sync_status", true);
    boolean syncNew = prefs.getBoolean("status_new", true);
    boolean syncLocation = prefs.getBoolean("sync_location", true);
    boolean syncSelf = prefs.getBoolean("sync_self", false);
    boolean imageDefault = prefs.getBoolean("image_primary", true);

    boolean oldStatus = sync && (!syncNew || (Build.VERSION.SDK_INT < 15));
    boolean faceDetect = true;

    boolean root = prefs.getBoolean("root_enabled", false);
    int rootSize = 512;

    if (FacebookUtil.authorize(context, account)) {

        HashMap<String, SyncEntry> localContacts = getLocalContacts(account);
        HashMap<String, Long> names = loadPhoneContacts(context);
        HashMap<String, Long> uids = loadHTCData(context);
        //Log.i("CONTACTS", names.toString());
        boolean phoneOnly = prefs.getBoolean("phone_only", true);
        /*if (phoneOnly){
           names = loadPhoneContacts(context);
        }*/
        boolean wifiOnly = prefs.getBoolean("wifi_only", false);
        boolean syncEmail = prefs.getBoolean("sync_facebook_email", false);
        boolean syncBirthday = prefs.getBoolean("sync_contact_birthday", true);
        boolean force = prefs.getBoolean("force_dl", false);
        boolean google = prefs.getBoolean("update_google_photos", false);
        boolean ignoreMiddleaNames = prefs.getBoolean("ignore_middle_names", false);
        boolean addMeToFriends = prefs.getBoolean("add_me_to_friends", false);
        Log.i("google", String.valueOf(google));
        int fuzziness = Integer.parseInt(prefs.getString("fuzziness", "2"));
        Set<String> addFriends = prefs.getStringSet("add_friends", new HashSet<String>());
        Log.i(TAG, "phone_only: " + Boolean.toString(phoneOnly));
        Log.i(TAG, "wifi_only: " + Boolean.toString(wifiOnly));
        Log.i(TAG, "is wifi: " + Boolean.toString(DeviceUtil.isWifi(context)));
        Log.i(TAG, "phone contacts: " + names.toString());
        Log.i(TAG, "using old status api: " + String.valueOf(oldStatus));
        Log.i(TAG, "ignoring middle names : " + String.valueOf(ignoreMiddleaNames));
        Log.i(TAG, "add me to friends : " + String.valueOf(addMeToFriends));
        boolean chargingOnly = prefs.getBoolean("charging_only", false);
        int maxsize = BitmapUtil.getMaxSize(context.getContentResolver());
        File cacheDir = context.getCacheDir();
        Log.i("CACHE DIR", cacheDir.getAbsolutePath());
        Log.i("MAX IMAGE SIZE", String.valueOf(maxsize));
        if (!((wifiOnly && !DeviceUtil.isWifi(context)) || (chargingOnly && !DeviceUtil.isCharging(context)))) {
            try {
                if (syncSelf) {
                    addSelfContact(account, maxsize, cropPhotos, faceDetect, force, root, rootSize, cacheDir,
                            google);
                }
                List<FacebookGraphFriend> friends = FacebookUtil.getFriends(maxsize, addMeToFriends);
                for (FacebookGraphFriend friend : friends) {
                    String uid = friend.getUserName();
                    String friendName = friend.getName(ignoreMiddleaNames);
                    if (friendName != null && uid != null) {
                        String match = matches(names.keySet(), friendName, fuzziness);

                        if (!(phoneOnly && (match == null) && !uids.containsKey(uid))
                                || addFriends.contains(friendName)) {
                            // STEP 1. Add contact - if the contact is not part of the HTCData records and does not match any
                            // of the fuzziness names we add them to the list of contacts with the intention to make them available
                            // for manual merge (I guess)
                            if (localContacts.get(uid) == null) {
                                //String name = friend.getString("name");
                                //Log.i(TAG, name + " already on phone: " + Boolean.toString(names.contains(name)));

                                addContact(account, friendName, uid);

                                SyncEntry entry = new SyncEntry();
                                Uri rawContactUr = RawContacts.CONTENT_URI.buildUpon()
                                        .appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
                                        .appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type)
                                        .appendQueryParameter(RawContacts.Data.DATA1, uid).build();
                                Cursor c = mContentResolver.query(rawContactUr,
                                        new String[] { BaseColumns._ID }, null, null, null);
                                c.moveToLast();
                                long id = c.getLong(c.getColumnIndex(BaseColumns._ID));
                                c.close();
                                //   Log.i("ID", Long.toString(id));
                                entry.raw_id = id;
                                localContacts.put(uid, entry);
                                if (uids.containsKey(uid)) {
                                    ContactUtil.merge(context, uids.get(uid), id);
                                } else if (names.containsKey(match)) {
                                    ContactUtil.merge(context, names.get(match), id);
                                }
                                //localContacts = loadContacts(accounts, context);
                            }

                            // STEP 2. Set contact photo

                            SyncEntry contact = localContacts.get(uid);

                            updateContactPhoto(contact.raw_id, friend.getPicTimestamp(), maxsize, cropPhotos,
                                    friend.getPicURL(), faceDetect, force, root, rootSize, cacheDir, google,
                                    imageDefault);

                            if (syncEmail && !FacebookUtil.RESPECT_FACEBOOK_POLICY)
                                ContactUtil.addEmail(context, contact.raw_id, friend.getEmail());

                            if (syncLocation && !FacebookUtil.RESPECT_FACEBOOK_POLICY) {
                                ContactUtil.updateContactLocation(contact.raw_id, friend.getLocation());
                            }

                            if (oldStatus && !FacebookUtil.RESPECT_FACEBOOK_POLICY) {
                                ArrayList<Status> statuses = friend.getStatuses();
                                if (statuses.size() >= 1) {
                                    updateContactStatus(contact.raw_id, statuses.get(0).getMessage(),
                                            statuses.get(0).getTimestamp());
                                }

                            }
                            if (syncBirthday && !FacebookUtil.RESPECT_FACEBOOK_POLICY) {
                                String birthday = friend.getBirthday();

                                if (birthday != null) {
                                    ContactUtil.addBirthday(contact.raw_id, birthday);
                                }
                            }

                        }
                    }
                }
            } catch (Exception e) {
                // FIXME catching the generic Exception class is not hte best thing to do
                Log.e("ERROR", e.toString());
            }

            if (root) {
                try {
                    RootUtil.refreshContacts();
                } catch (ShellException e) {
                    Log.e("Error", e.getLocalizedMessage());
                }
            }
            if (force) {
                SharedPreferences.Editor editor = prefs.edit();
                editor.putBoolean("force_dl", false);
                editor.commit();

            }

        } else {
            SharedPreferences.Editor editor = prefs.edit();
            editor.putBoolean("missed_contact_sync", true);
            editor.commit();
        }
    }
}

From source file:com.jvoid.products.product.service.ProductsMasterService.java

public Integer addProduct(ProductsMaster productsMaster) {
    int pid = 0;//  www .  ja  va 2s  .  c  om

    Product product = new Product();
    product.setCreatedOn(Utilities.getCurrentDateTime());
    product.setUpdatedOn(Utilities.getCurrentDateTime());
    product.setSku(productsMaster.getSku());
    product.setHasOptions(productsMaster.getHasMoreOption());
    product.setRequiredOptions(productsMaster.getRequiredOption());
    product.setType(productsMaster.getType());

    productService.addproduct(product);
    pid = product.getId();
    System.out.println("customer==>" + product.toString());

    //add CategoryProduct entry
    int categoryId = productsMaster.getCategoryId();
    int categoryProductId = 0;
    if (categoryId > 0) {
        categoryProductId = addProductToCategory(categoryId, pid);
    }

    /*//rest call
    final String SERVER_URI = "http://localhost:8080/jvoidattributes/listProductAttriburtes";
    RestTemplate restTemplate = new RestTemplate();
            
    String returnString = restTemplate.getForObject(SERVER_URI, String.class);        
      JSONObject returnJsonObj = null;
    try {
       returnJsonObj = new JSONObject(returnString);
    } catch (JSONException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }
            
      System.out.println("returnJsonObj=>"+returnJsonObj);
              
      JSONArray arr = null;
      try {
       arr = returnJsonObj.getJSONArray("Attributes");
    } catch (JSONException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }
              
      for (int i=0; i<arr.length(); i++) {
        try {
    String attrValue = arr.getJSONObject(i).getString("code");
    Integer attrId = Integer.parseInt(arr.getJSONObject(i).getString("id"));
    System.out.println("id = "+attrId+"   code = "+attrValue);
            
    ProductAttributeValues prodAttrValue = new ProductAttributeValues();
     prodAttrValue.setProductId(product.getId());
     prodAttrValue.setLanguage("enUS");
     prodAttrValue.setAttributeId(attrId);
     prodAttrValue.setValue(productsMaster.toAttributedHashMap().get(attrValue));
     productAttributeValuesService.addProductAttributeValues(prodAttrValue);
     System.out.println("custAttrValue-->"+prodAttrValue.toString());
       } catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
       }
    }
    */

    List<Entities> listAttributes = this.entitiesService.listAttributes();
    HashMap<Integer, String> attrs = getAttributesList(listAttributes, "Product");
    System.out.println("attrs==>" + attrs.toString());

    for (Entry<Integer, String> entry : attrs.entrySet()) {
        Integer attrId = entry.getKey();
        String attrValue = entry.getValue();

        ProductEntityValues prodAttrValue = new ProductEntityValues();
        prodAttrValue.setProductId(product.getId());
        prodAttrValue.setLanguage("enUS");
        prodAttrValue.setAttributeId(attrId);
        prodAttrValue.setValue(productsMaster.toAttributedHashMap().get(attrValue));
        productEntityValuesService.addProductAttributeValues(prodAttrValue);
        System.out.println("custAttrValue-->" + prodAttrValue.toString());
    }
    return pid;
}

From source file:org.hfoss.posit.web.Communicator.java

public boolean sendFind(Find find, String action) {
    boolean success = false;
    String url;/*w  w w. j a  va 2s .  co  m*/
    HashMap<String, String> sendMap = find.getContentMapGuid();
    //Log.i(TAG, "sendFind map = " + sendMap.toString());
    cleanupOnSend(sendMap);
    sendMap.put("imei", imei);
    String guid = sendMap.get(PositDbHelper.FINDS_GUID);

    // Create the url

    if (action.equals("create")) {
        url = server + "/api/createFind?authKey=" + authKey;
    } else {
        url = server + "/api/updateFind?authKey=" + authKey;
    }
    if (Utils.debug) {
        Log.i(TAG, "SendFind=" + sendMap.toString());
    }

    // Send the find
    try {
        responseString = doHTTPPost(url, sendMap);
    } catch (Exception e) {
        Log.i(TAG, e.getMessage());
        Utils.showToast(mContext, e.getMessage());
    }
    if (Utils.debug)
        Log.i(TAG, "sendFind.ResponseString: " + responseString);

    // If the update failed return false
    if (responseString.indexOf("True") == -1) {
        Log.i(TAG, "sendFind result doesn't contain 'True'");
        return false;
    } else {
        PositDbHelper dbh = new PositDbHelper(mContext);
        long id = find.getId();
        success = dbh.markFindSynced(id);
        if (Utils.debug)
            Log.i(TAG, "sendfind synced " + id + " " + success);
    }

    if (!success)
        return false;

    // Otherwise send the Find's images

    long id = Long.parseLong(sendMap.get(PositDbHelper.FINDS_ID));
    PositDbHelper dbh = new PositDbHelper(mContext);
    ArrayList<ContentValues> photosList = dbh.getImagesListSinceUpdate(id);

    Log.i(TAG, "sendFind, photosList=" + photosList.toString());

    Iterator<ContentValues> it = photosList.listIterator();
    while (it.hasNext()) {
        ContentValues imageData = it.next();
        Uri uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_IMAGE_URI));
        String base64Data = convertUriToBase64(uri);
        uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_THUMBNAIL_URI));
        String base64Thumbnail = convertUriToBase64(uri);
        sendMap = new HashMap<String, String>();
        sendMap.put(COLUMN_IMEI, Utils.getIMEI(mContext));
        sendMap.put(PositDbHelper.FINDS_GUID, guid);

        sendMap.put(PositDbHelper.PHOTOS_IDENTIFIER, imageData.getAsString(PositDbHelper.PHOTOS_IDENTIFIER));
        sendMap.put(PositDbHelper.FINDS_PROJECT_ID, imageData.getAsString(PositDbHelper.FINDS_PROJECT_ID));
        sendMap.put(PositDbHelper.FINDS_TIME, imageData.getAsString(PositDbHelper.FINDS_TIME));
        sendMap.put(PositDbHelper.PHOTOS_MIME_TYPE, imageData.getAsString(PositDbHelper.PHOTOS_MIME_TYPE));

        sendMap.put("mime_type", "image/jpeg");

        sendMap.put(PositDbHelper.PHOTOS_DATA_FULL, base64Data);
        sendMap.put(PositDbHelper.PHOTOS_DATA_THUMBNAIL, base64Thumbnail);
        sendMedia(sendMap);
        //it.next();
    }

    // Update the Synced attribute.
    return true;
}

From source file:com.datatorrent.lib.db.jdbc.AbstractJdbcPollInputOperator.java

private HashMap<Integer, KeyValPair<Integer, Integer>> getPartitionedQueryRangeMap(int partitions)
        throws SQLException {
    int rowCount = 0;
    try {/*from   ww w .ja va 2  s. c o m*/
        rowCount = getRecordsCount();
    } catch (SQLException e) {
        LOG.error("Exception in getting the record range", e);
    }

    HashMap<Integer, KeyValPair<Integer, Integer>> partitionToQueryMap = new HashMap<>();
    int events = (rowCount / partitions);
    for (int i = 0, lowerOffset = 0, upperOffset = events; i < partitions
            - 1; i++, lowerOffset += events, upperOffset += events) {
        partitionToQueryMap.put(i, new KeyValPair<Integer, Integer>(lowerOffset, upperOffset));
    }

    partitionToQueryMap.put(partitions - 1,
            new KeyValPair<Integer, Integer>(events * (partitions - 1), (int) rowCount));
    LOG.info("Partition map - " + partitionToQueryMap.toString());
    return partitionToQueryMap;
}

From source file:org.eurekastreams.server.persistence.mappers.stream.ActivityContentExtractor.java

/**
 * Extract the unformatted content from the activity for analysis.
 *
 * @param inBaseObjectType//from   w ww.j a va 2s  .  c  o m
 *            the activity base type
 * @param inBaseObject
 *            the map of properties
 * @return unformatted content from the activity
 */
public String extractContent(final BaseObjectType inBaseObjectType,
        final HashMap<String, String> inBaseObject) {
    StringBuffer sb = new StringBuffer();
    if (inBaseObject != null) {
        switch (inBaseObjectType) {
        case NOTE:
            if (inBaseObject.containsKey("content")) {
                sb.append(inBaseObject.get("content"));
            }
            break;
        case BOOKMARK:
            if (inBaseObject.containsKey("content")) {
                sb.append(inBaseObject.get("content"));
            }
            if (inBaseObject.containsKey("targetTitle")) {
                sb.append(" ");
                sb.append(inBaseObject.get("targetTitle"));
            }
            if (inBaseObject.containsKey("description")) {
                sb.append(" ");
                sb.append(inBaseObject.get("description"));
            }
            break;
        case FILE:
            if (inBaseObject.containsKey("targetTitle")) {
                sb.append(inBaseObject.get("targetTitle"));
            }
            break;
        default:
            log.error(
                    "I don't know how to pull the content from activities of type: " + inBaseObject.toString());
            break;
        }
    }

    return sb.toString().length() > 0 ? sb.toString() : null;
}

From source file:org.mifosplatform.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java

@Override
public PreviewCampaignMessage previewMessage(final JsonQuery query) {
    PreviewCampaignMessage campaignMessage = null;
    final AppUser currentUser = this.context.authenticatedUser();
    this.emailCampaignValidator.validatePreviewMessage(query.json());
    final String emailParams = this.fromJsonHelper.extractStringNamed("paramValue", query.parsedJson());
    final String textMessageTemplate = this.fromJsonHelper.extractStringNamed("emailMessage",
            query.parsedJson());//from   w ww  .j a v  a2s  . c  om

    final Long campaignId = this.fromJsonHelper.extractLongNamed("campaignId", query.parsedJson());

    EmailCampaign emailCampaign = null;
    HashMap<String, String> reportStretchyParams = null;

    if (campaignId != null) {
        emailCampaign = this.emailCampaignRepository.findOne(campaignId);
        reportStretchyParams = this.validateStretchyReportParamMap(emailCampaign.getStretchyReportParamMap());
    }

    try {
        HashMap<String, String> campaignParams = new ObjectMapper().readValue(emailParams,
                new TypeReference<HashMap<String, String>>() {
                });

        HashMap<String, String> queryParamForRunReport = new ObjectMapper().readValue(emailParams,
                new TypeReference<HashMap<String, String>>() {
                });

        List<HashMap<String, Object>> runReportObject = this
                .getRunReportByServiceImpl(campaignParams.get("reportName"), queryParamForRunReport);
        // preview attachment report params

        if (runReportObject != null) {
            for (HashMap<String, Object> entry : runReportObject) {
                // add string object to campaignParam object
                String textMessage = this.compileEmailTemplate(textMessageTemplate, "EmailCampaign", entry);
                if (!textMessage.isEmpty()) {
                    final Integer totalMessage = runReportObject.size();
                    String reportStretchyParam = null;
                    Object var = "id";
                    Integer clientId = (Integer) entry.get(var);
                    final Client client = this.clientRepository.findOne(clientId.longValue());
                    if (reportStretchyParams != null) {
                        HashMap<String, String> reportParams = this
                                .replaceStretchyParamsWithActualClientParams(reportStretchyParams, client);
                        this.replaceStretchyParamsWithActualLoansOrSavingsParam(reportStretchyParams, client); // add loans or savings id to report params only one object
                        if (reportParams != null) {
                            reportStretchyParam = reportParams.toString();
                        }
                    }
                    campaignMessage = new PreviewCampaignMessage(textMessage, totalMessage,
                            reportStretchyParam);
                    break;
                }
            }
        }
    } catch (final IOException e) {
        // TODO throw something here
    }

    return campaignMessage;

}

From source file:org.restcomm.android.olympus.CallActivity.java

private void handleCall(Intent intent) {
    if (intent.getAction().equals(RCDevice.ACTION_RESUME_CALL)) {
        String text;/*from  w  ww  .  j a v a 2s . c om*/
        connection = device.getLiveConnection();
        if (connection != null) {
            connection.setConnectionListener(this);

            if (connection.isIncoming()) {
                // Incoming
                if (connection.getRemoteMediaType() == AUDIO_VIDEO) {
                    text = "Video Call from ";
                } else {
                    text = "Audio Call from ";
                }
            } else {
                // Outgoing
                if (connection.getLocalMediaType() == AUDIO_VIDEO) {
                    text = "Video Calling ";
                } else {
                    text = "Audio Calling ";
                }
            }

            lblCall.setText(text + connection.getPeer().replaceAll(".*?sip:", "").replaceAll("@.*$", ""));
            lblStatus.setText("Connected");
            connection.reattachVideo((PercentFrameLayout) findViewById(R.id.local_video_layout),
                    (PercentFrameLayout) findViewById(R.id.remote_video_layout));

            // Get the time when we paused call so that now that we are resuming we can show correct time
            long difference = (System.currentTimeMillis() - prefs.getLong(LIVE_CALL_PAUSE_TIME, 0));
            int duration = (int) (difference / 1000);
            startTimer(duration);

            // resume UI state
            muteAudio = connection.isAudioMuted();
            muteVideo = connection.isVideoMuted();
            if (connection.isAudioMuted()) {
                btnMuteAudio.setImageResource(R.drawable.audio_muted);
            }
            if (connection.getLocalMediaType() != AUDIO_VIDEO) {
                btnMuteVideo.setEnabled(false);
                btnMuteVideo.setColorFilter(
                        Color.parseColor(getString(R.string.string_color_filter_video_disabled)));
            } else {
                if (connection.isVideoMuted()) {
                    btnMuteVideo.setImageResource(R.drawable.video_muted);
                }
            }

            // Hide answering buttons and show mute & keypad
            btnAnswer.setVisibility(View.INVISIBLE);
            btnAnswerAudio.setVisibility(View.INVISIBLE);
            btnMuteAudio.setVisibility(View.VISIBLE);
            btnMuteVideo.setVisibility(View.VISIBLE);
            btnKeypad.setVisibility(View.VISIBLE);
            lblTimer.setVisibility(View.VISIBLE);
        } else {
            showOkAlert("Resume ongoing call", "No call to resume");
        }

        return;
    }

    if (connection != null) {
        return;
    }

    isVideo = intent.getBooleanExtra(RCDevice.EXTRA_VIDEO_ENABLED, false);
    if (intent.getAction().equals(RCDevice.ACTION_OUTGOING_CALL)) {
        String text;
        if (isVideo) {
            text = "Video Calling ";
        } else {
            text = "Audio Calling ";
        }

        lblCall.setText(text
                + intent.getStringExtra(RCDevice.EXTRA_DID).replaceAll(".*?sip:", "").replaceAll("@.*$", ""));
        lblStatus.setText("Initiating Call...");

        connectParams = new HashMap<String, Object>();
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER,
                intent.getStringExtra(RCDevice.EXTRA_DID));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED,
                intent.getBooleanExtra(RCDevice.EXTRA_VIDEO_ENABLED, false));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO,
                (PercentFrameLayout) findViewById(R.id.local_video_layout));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO,
                (PercentFrameLayout) findViewById(R.id.remote_video_layout));
        // by default we use VP8 for video as it tends to be more adopted, but you can override that and specify VP9 or H264 as follows:
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, audioCodecString2Enum(
                prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, "")));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, videoCodecString2Enum(
                prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, "")));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION,
                resolutionString2Enum(
                        prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, "")));
        connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE,
                frameRateString2Enum(
                        prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, "")));
        // Needed until we implement Trickle ICE
        connectParams.put(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, Integer
                .parseInt(prefs.getString(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, "0")));

        // Here's how to set manually
        //connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, RCConnection.VideoCodec.VIDEO_CODEC_VP8);
        //connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, RCConnection.VideoResolution.RESOLUTION_HD_1280x720);
        //connectParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, RCConnection.VideoFrameRate.FPS_DEFAULT);

        // *** if you want to add custom SIP headers, please uncomment this
        //HashMap<String, String> sipHeaders = new HashMap<>();
        //sipHeaders.put("X-SIP-Header1", "Value1");
        //connectParams.put(RCConnection.ParameterKeys.CONNECTION_CUSTOM_SIP_HEADERS, sipHeaders);

        // save peer to preferences, we might need it for potential bug report (check BugReportActivity)
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(BugReportActivity.MOST_RECENT_CALL_PEER, intent.getStringExtra(RCDevice.EXTRA_DID));
        editor.apply();

        handlePermissions(isVideo);
    }
    if (intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL)
            || intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_AUDIO)
            || intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_VIDEO)) {
        String text;
        if (isVideo) {
            text = "Video Call from ";
        } else {
            text = "Audio Call from ";
        }

        lblCall.setText(text
                + intent.getStringExtra(RCDevice.EXTRA_DID).replaceAll(".*?sip:", "").replaceAll("@.*$", ""));
        lblStatus.setText("Call Received...");

        //callOutgoing = false;
        pendingConnection = device.getPendingConnection();
        // There is chance that pendingConnection is null if call activity is reopened after call has failed
        // but used hasn't pressed ok to the dialog so that the call activity is destroyed. Let's guard for this
        if (pendingConnection != null) {
            pendingConnection.setConnectionListener(this);

            // the number from which we got the call
            String incomingCallDid = intent.getStringExtra(RCDevice.EXTRA_DID);
            HashMap<String, String> customHeaders = (HashMap<String, String>) intent
                    .getSerializableExtra(RCDevice.EXTRA_CUSTOM_HEADERS);
            if (customHeaders != null) {
                Log.i(TAG, "Got custom headers in incoming call: " + customHeaders.toString());
            }

            // save peer to preferences, we might need it for potential bug report (check BugReportActivity)
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString(BugReportActivity.MOST_RECENT_CALL_PEER, incomingCallDid);
            editor.apply();

            if (intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_AUDIO)
                    || intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_VIDEO)) {
                // The Intent has been sent from the Notification subsystem. It can be either of type 'decline', 'video answer and 'audio answer'
                boolean answerVideo = intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_VIDEO);
                btnAnswer.setVisibility(View.INVISIBLE);
                btnAnswerAudio.setVisibility(View.INVISIBLE);

                acceptParams = new HashMap<String, Object>();
                acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, answerVideo);
                acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO,
                        (PercentFrameLayout) findViewById(R.id.local_video_layout));
                acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO,
                        (PercentFrameLayout) findViewById(R.id.remote_video_layout));
                acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC,
                        audioCodecString2Enum(prefs
                                .getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, "")));
                // Needed until we implement Trickle ICE
                acceptParams.put(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT,
                        Integer.parseInt(prefs.getString(
                                RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, "0")));

                if (intent.getAction().equals(RCDevice.ACTION_INCOMING_CALL_ANSWER_VIDEO)) {
                    acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC,
                            videoCodecString2Enum(prefs.getString(
                                    RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, "")));
                    acceptParams
                            .put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION,
                                    resolutionString2Enum(prefs.getString(
                                            RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION,
                                            "")));
                    acceptParams
                            .put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE,
                                    frameRateString2Enum(prefs.getString(
                                            RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE,
                                            "")));
                }

                // Check permissions asynchronously and then accept the call
                handlePermissions(answerVideo);
            }
        } else {
            Log.w(TAG, "Warning: pendingConnection is null, probably reusing past intent");
        }
    }
}

From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java

@Override
public PreviewCampaignMessage previewMessage(final JsonQuery query) {
    PreviewCampaignMessage campaignMessage = null;
    final AppUser currentUser = this.context.authenticatedUser();
    this.emailCampaignValidator.validatePreviewMessage(query.json());
    final String emailParams = this.fromJsonHelper.extractStringNamed("paramValue", query.parsedJson());
    final String textMessageTemplate = this.fromJsonHelper.extractStringNamed("emailMessage",
            query.parsedJson());/*from   w ww . ja  v a  2s . co m*/

    final Long campaignId = this.fromJsonHelper.extractLongNamed("campaignId", query.parsedJson());

    EmailCampaign emailCampaign = null;
    HashMap<String, String> reportStretchyParams = null;

    if (campaignId != null) {
        emailCampaign = this.emailCampaignRepository.findOne(campaignId);
        reportStretchyParams = this.validateStretchyReportParamMap(emailCampaign.getStretchyReportParamMap());
    }

    try {
        HashMap<String, String> campaignParams = new ObjectMapper().readValue(emailParams,
                new TypeReference<HashMap<String, String>>() {
                });

        HashMap<String, String> queryParamForRunReport = new ObjectMapper().readValue(emailParams,
                new TypeReference<HashMap<String, String>>() {
                });

        List<HashMap<String, Object>> runReportObject = this
                .getRunReportByServiceImpl(campaignParams.get("reportName"), queryParamForRunReport);
        // preview attachment report params

        if (runReportObject != null) {
            for (HashMap<String, Object> entry : runReportObject) {
                // add string object to campaignParam object
                String textMessage = this.compileEmailTemplate(textMessageTemplate, "EmailCampaign", entry);
                if (!textMessage.isEmpty()) {
                    final Integer totalMessage = runReportObject.size();
                    String reportStretchyParam = null;
                    Object var = "id";
                    Integer clientId = (Integer) entry.get(var);
                    final Client client = this.clientRepositoryWrapper
                            .findOneWithNotFoundDetection(clientId.longValue());
                    if (reportStretchyParams != null) {
                        HashMap<String, String> reportParams = this
                                .replaceStretchyParamsWithActualClientParams(reportStretchyParams, client);
                        this.replaceStretchyParamsWithActualLoansOrSavingsParam(reportStretchyParams, client); // add loans or savings id to report params only one object
                        if (reportParams != null) {
                            reportStretchyParam = reportParams.toString();
                        }
                    }
                    campaignMessage = new PreviewCampaignMessage(textMessage, totalMessage,
                            reportStretchyParam);
                    break;
                }
            }
        }
    } catch (final IOException e) {
        // TODO throw something here
    }

    return campaignMessage;

}

From source file:org.hfoss.posit.android.web.Communicator.java

public boolean sendFind(Find find, String action) {
    boolean success = false;
    String url;// w  w  w  .j a va2s. c  om
    HashMap<String, String> sendMap = find.getContentMapGuid();
    // Log.i(TAG, "sendFind map = " + sendMap.toString());
    cleanupOnSend(sendMap);
    sendMap.put("imei", imei);
    String guid = sendMap.get(PositDbHelper.FINDS_GUID);
    long id = find.getId();
    // Create the url

    if (action.equals("create")) {
        url = server + "/api/createFind?authKey=" + authKey;
    } else {
        url = server + "/api/updateFind?authKey=" + authKey;
    }
    if (Utils.debug) {
        Log.i(TAG, "SendFind=" + sendMap.toString());
    }

    // Send the find
    try {
        responseString = doHTTPPost(url, sendMap);
    } catch (Exception e) {
        Log.i(TAG, e.getMessage());
        Utils.showToast(mContext, e.getMessage());
        return false;
    }
    if (Utils.debug)
        Log.i(TAG, "sendFind.ResponseString: " + responseString);

    // If the update failed return false
    if (responseString.indexOf("True") == -1) {
        Log.i(TAG, "sendFind result doesn't contain 'True'");
        return false;
    } else {
        PositDbHelper dbh = new PositDbHelper(mContext);
        success = dbh.markFindSynced(id);
        if (Utils.debug)
            Log.i(TAG, "sendfind synced " + id + " " + success);
    }

    if (success) {
        // Otherwise send the Find's images

        //long id = Long.parseLong(sendMap.get(PositDbHelper.FINDS_ID));
        PositDbHelper dbh = new PositDbHelper(mContext);
        ArrayList<ContentValues> photosList = dbh.getImagesListSinceUpdate(id, projectId);

        Log.i(TAG, "sendFind, photosList=" + photosList.toString());

        Iterator<ContentValues> it = photosList.listIterator();
        while (it.hasNext()) {
            ContentValues imageData = it.next();
            Uri uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_IMAGE_URI));
            String base64Data = convertUriToBase64(uri);
            uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_THUMBNAIL_URI));
            String base64Thumbnail = convertUriToBase64(uri);
            sendMap = new HashMap<String, String>();
            sendMap.put(COLUMN_IMEI, Utils.getIMEI(mContext));
            sendMap.put(PositDbHelper.FINDS_GUID, guid);

            sendMap.put(PositDbHelper.PHOTOS_IDENTIFIER,
                    imageData.getAsString(PositDbHelper.PHOTOS_IDENTIFIER));
            sendMap.put(PositDbHelper.FINDS_PROJECT_ID, imageData.getAsString(PositDbHelper.FINDS_PROJECT_ID));
            sendMap.put(PositDbHelper.FINDS_TIME, imageData.getAsString(PositDbHelper.FINDS_TIME));
            sendMap.put(PositDbHelper.PHOTOS_MIME_TYPE, imageData.getAsString(PositDbHelper.PHOTOS_MIME_TYPE));

            sendMap.put("mime_type", "image/jpeg");

            sendMap.put(PositDbHelper.PHOTOS_DATA_FULL, base64Data);
            sendMap.put(PositDbHelper.PHOTOS_DATA_THUMBNAIL, base64Thumbnail);
            sendMedia(sendMap);
        }
    }
    // Update the Synced attribute.
    return success;
}

From source file:org.apache.zeppelin.cluster.ClusterManager.java

public HashMap<String, HashMap<String, Object>> getClusterMeta(ClusterMetaType metaType, String metaKey) {
    HashMap<String, HashMap<String, Object>> clusterMeta = new HashMap<>();
    if (!raftInitialized()) {
        LOGGER.error("Raft incomplete initialization!");
        return clusterMeta;
    }/*from w ww.java 2  s.  c om*/

    ClusterMetaEntity entity = new ClusterMetaEntity(GET_OPERATION, metaType, metaKey, null);

    byte[] mateData = null;
    try {
        mateData = raftSessionClient
                .execute(operation(ClusterStateMachine.GET, clientSerializer.encode(entity)))
                .get(3, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        LOGGER.error(e.getMessage());
    } catch (ExecutionException e) {
        LOGGER.error(e.getMessage());
    } catch (TimeoutException e) {
        LOGGER.error(e.getMessage());
    }

    if (null != mateData) {
        clusterMeta = clientSerializer.decode(mateData);
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("getClusterMeta >>> {}", clusterMeta.toString());
    }

    return clusterMeta;
}