Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

In this page you can find the example usage for java.lang String contentEquals.

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:org.jtrfp.trcl.gui.ConfigWindow.java

private boolean isBuiltinVOX(String vox) {
    return vox.contentEquals(TRConfiguration.AUTO_DETECT) || vox.contentEquals("Fury3")
            || vox.contentEquals("TV") || vox.contentEquals("FurySE");
}

From source file:com.lunabeat.dooper.HadoopCluster.java

/**
 *
 * @return userdata file contents after placeholder substitution placeholder
 * @throws IOException// w  ww.  j  ava 2 s  . com
 */
public String getUserData() throws IOException {
    update();
    StringBuilder userData = new StringBuilder();
    FileReader fr = new FileReader(_config.get(ClusterConfig.USER_DATA_PATH_KEY));
    if (fr == null) {
        throw new IOException("Could NOT open resource: [" + ClusterConfig.USER_DATA_PATH_KEY + "]");
    }
    BufferedReader buf = new BufferedReader(fr);
    String line = null;
    while ((line = buf.readLine()) != null) {
        Matcher matches = userDataValue.matcher(line);
        if (!matches.find()) {
            userData.append(line);
            userData.append("\n");
            continue;
        }

        String key = matches.group(1);
        String value = "\"\"";
        if (key.contentEquals(ClusterConfig.MASTER_HOST_KEY)) {
            if (_master != null) {
                value = _master.getInstance().getPrivateDnsName();
            }
        } else {
            value = _config.get(key, value);
        }
        line = line.replaceAll("%" + key + "%", value);
        userData.append(line);
        userData.append("\n");
    }

    if (userData.length() < 1) {
        return null;
    }
    return userData.toString();
}

From source file:de.enlightened.peris.ThemeEditor.java

private void juiceUpOptions() {
    final Button btnAccent = (Button) findViewById(R.id.theme_editor_accent_color);
    btnAccent.setOnClickListener(new OnClickListener() {

        @Override//from   w w w  .j  ava  2 s .  c om
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            final ColorPickerDialogFragment newFragment = ColorPickerDialogFragment.newInstance();
            newFragment.setOnColorSelectedListener(new ColorPickerDialogFragment.ColorSelectedListener() {

                public void onColorSelected(final String color) {
                    setColor(color);
                }
            });
            newFragment.show(getSupportFragmentManager(), "dialog");
        }
    });

    final Button btnBackground = (Button) findViewById(R.id.theme_editor_background_color);
    btnBackground.setOnClickListener(new OnClickListener() {

        @Override
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            final ColorPickerDialogFragment newFragment = ColorPickerDialogFragment.newInstance();
            newFragment.setOnColorSelectedListener(new ColorPickerDialogFragment.ColorSelectedListener() {

                public void onColorSelected(final String color) {
                    setBackground(color);
                }
            });
            newFragment.show(getSupportFragmentManager(), "dialog");
        }
    });

    final Button btnTextColor = (Button) findViewById(R.id.theme_editor_text_color);
    btnTextColor.setOnClickListener(new OnClickListener() {

        @Override
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            final ColorPickerDialogFragment newFragment = ColorPickerDialogFragment.newInstance();
            newFragment.setOnColorSelectedListener(new ColorPickerDialogFragment.ColorSelectedListener() {

                public void onColorSelected(final String color) {
                    setTextColor(color);
                }
            });
            newFragment.show(getSupportFragmentManager(), "dialog");
        }
    });

    final Button btnElementBorder = (Button) findViewById(R.id.theme_editor_borders);
    btnElementBorder.setOnClickListener(new OnClickListener() {

        @Override
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            String currentSetting = getString(R.string.default_element_border);

            if (application.getSession().getServer().serverBoxBorder != null) {
                currentSetting = application.getSession().getServer().serverBoxBorder;
            }

            if (currentSetting.contentEquals("1")) {
                application.getSession().getServer().serverBoxBorder = "0";
            } else {
                application.getSession().getServer().serverBoxBorder = "1";
            }

            application.getSession().updateServer();

            updatePreview();
        }
    });

    final Button btnElementColor = (Button) findViewById(R.id.theme_editor_element_color);
    btnElementColor.setOnClickListener(new OnClickListener() {

        @Override
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            final ColorPickerDialogFragment newFragment = ColorPickerDialogFragment.newInstance();

            final Bundle bundle = new Bundle();
            bundle.putBoolean("show_opacity", true);
            newFragment.setArguments(bundle);

            newFragment.setOnColorSelectedListener(new ColorPickerDialogFragment.ColorSelectedListener() {

                public void onColorSelected(final String color) {
                    setElementColor(color);
                }
            });
            newFragment.show(getSupportFragmentManager(), "dialog");
        }
    });

    final Button btnWallpaper = (Button) findViewById(R.id.theme_editor_wallpaper);
    btnWallpaper.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            final BackgroundUrlDialogFragment newFragment = BackgroundUrlDialogFragment.newInstance();
            newFragment.show(getSupportFragmentManager(), "dialog");
        }
    });
}

From source file:com.company.millenium.iwannask.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param data GCM message received.//from w  ww  .  ja  va 2 s  .c om
 */
private void sendNotification(Bundle data) {
    String question_body = data.getString("question_body");
    String answer_body = data.getString("answer_body");
    String question_id = data.getString("question_id");
    //String answer_id = data.getString("answer_id");
    String user_name = data.getString("user_name");
    if (user_name != null && user_name.contains(" ")) {
        user_name = user_name.split(" ")[0];
    }
    String type = data.getString("type");

    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra("url", "/questions/" + question_id);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    String info = " answered:";
    if (type != null && type.contentEquals("answer_feedback")) {
        String isLiked = data.getString("feedback_value");
        info = " disliked your answer";
        if (isLiked != null && isLiked.equals("true")) {
            info = " liked your answer";
        }
    } else if (type != null && type.contentEquals("question_answer_op")) {
        info = " commented on";
    }
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_comment_question_outline_grey600_36dp).setContentTitle(user_name + info)
            .setContentText(question_body)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(question_body + "\n" + answer_body))
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(id, notificationBuilder.build());
    id = id + 1;
}

From source file:com.nuvolect.securesuite.util.OmniFile.java

/**
 * Create an OmniFile from a volumeHash which has the
 * volume id on the front end of a hash.
 * @param volumeHash/*  ww  w.j  a va 2  s .  c o  m*/
 */
public OmniFile(String volumeHash) {

    if (volumeHash.startsWith("/"))
        volumeHash = volumeHash.substring(1);

    m_volumeHash = volumeHash;
    String segments[] = volumeHash.split("_");
    m_volumeId = segments[0];
    m_isRoot = Omni.isRoot(volumeHash);
    m_isCryp = m_volumeId.contentEquals(Omni.cryptoVolumeId);

    String path = (OmniHash.decode(segments[1]) + "/").replace("//", "/");
    String rootPath = Omni.getRoot(m_volumeId);
    if (!rootPath.contentEquals("/"))
        path = (rootPath + path).replace("//", "/");

    if (m_isCryp)
        m_cry_file = new info.guardianproject.iocipher.File(path);
    else
        m_std_file = new java.io.File(path);

    if (DEBUG)
        calcDebug("OmniFile( volumeHash)");
}

From source file:ch.elexis.importer.div.Test_HL7_parser.java

/**
 * Rothen filled the HL7 field(8) with 'N' if there was no patholical value found
 * /*from  w ww . java2s  . co  m*/
 * @throws IOException
 */
@Test
public void testRothenPatholical() throws IOException {
    removeAllPatientsAndDependants();
    removeAllLaboWerte();
    parseOneHL7file(hlp, new File(workDir.toString(), "Rothen/1_Kunde_20090612083757162_10009977_.HL7"), false,
            true);
    Query<LabResult> qr = new Query<LabResult>(LabResult.class);
    qr.orderBy(false, LabResult.ITEM_ID, LabResult.DATE, LabResult.RESULT);
    List<LabResult> qrr = qr.execute();
    assertEquals(40, qrr.size());

    int j = 0;
    Query<LabItem> query = new Query<LabItem>(LabItem.class);
    query.orderBy(false, LabItem.SHORTNAME);
    LabItem item = null;
    j = 0;
    LabResult res = null;
    boolean foundLymphozyten = false;
    boolean foundPathological = false;
    for (j = 0; j < qrr.size(); j++) {
        // dumpLabresult(qrr.get(j));
        LabItem li = (LabItem) qrr.get(j).getItem();
        String name = li.getName();
        assertTrue(qrr.get(j).getAnalyseTime().getTime().toString().contains("2009"));
        assertTrue(qrr.get(j).getAnalyseTime().getTime().toString().contains("Jun 11"));
        if (name.contentEquals("Lymphozyten G/l")) {
            foundLymphozyten = true;
            res = qrr.get(j);
            item = (LabItem) qrr.get(j).getItem();
        }

        if (name.contentEquals("MCV") || name.contentEquals("Basophile%")
                || name.contentEquals("Triglyceride")) {
            assertTrue(qrr.get(j).isFlag(LabResultConstants.PATHOLOGIC));
            assertTrue(qrr.get(j).getFlags() == LabResultConstants.PATHOLOGIC);
            foundPathological = true;
        } else {
            assertFalse(qrr.get(j).isFlag(LabResultConstants.PATHOLOGIC));
        }
        if (foundPathological && foundLymphozyten)
            break;
    }
    System.out.println(qrr.size());
    assertEquals(40, qrr.size());
    assertTrue(foundPathological);
    assertTrue(foundLymphozyten);
    assertNotNull(item);
    assertEquals("G/l", item.getEinheit());
    assertEquals("lymA_B", item.getKuerzel());
    assertEquals("Lymphozyten G/l", item.getName());
    assertEquals(LabItemTyp.TEXT, item.getTyp());
    // assertEquals(typ.NUMERIC, item.getTyp());
    assertTrue(item.getGroup().contains(Messages.HL7Parser_AutomaticAddedGroup));
    assertNotNull(res);
    assertEquals(res.getResult(), "1.6");
}

From source file:de.enlightened.peris.MessageActivity.java

private void renderMessage(final Message message) {
    final Context context = this.getApplicationContext();
    final SharedPreferences appPreferences = context.getSharedPreferences("prefs", 0);
    final boolean useShading = appPreferences.getBoolean("use_shading", false);
    final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false);
    final int fontSize = appPreferences.getInt("font_size", DEFAULT_FONT_SIZE);
    final boolean currentAvatarSetting = appPreferences.getBoolean("show_images", true);
    final Typeface opensans = Typeface.createFromAsset(context.getAssets(), "fonts/opensans.ttf");

    final View view = this.findViewById(R.id.message_layout);
    final TextView poAuthor = (TextView) view.findViewById(R.id.message_author);
    final TextView poTimestamp = (TextView) view.findViewById(R.id.message_timestamp);
    final TextView tvOnline = (TextView) view.findViewById(R.id.message_online_status);

    final LinearLayout llBorderBackground = (LinearLayout) view.findViewById(R.id.ll_border_background);
    final LinearLayout llColorBackground = (LinearLayout) view.findViewById(R.id.ll_color_background);

    String textColor = context.getString(R.string.default_text_color);
    if (this.application.getSession().getServer().serverTextColor.contains("#")) {
        textColor = this.application.getSession().getServer().serverTextColor;
    }/*from  ww  w. j ava  2  s .com*/

    String boxColor = context.getString(R.string.default_element_background);
    if (this.application.getSession().getServer().serverBoxColor != null) {
        boxColor = this.application.getSession().getServer().serverBoxColor;
    }

    if (boxColor.contains("#")) {
        llColorBackground.setBackgroundColor(Color.parseColor(boxColor));
    } else {
        llColorBackground.setBackgroundColor(Color.TRANSPARENT);
    }

    //TODO: remove border?
    String boxBorder = context.getString(R.string.default_element_border);
    if (this.application.getSession().getServer().serverBoxBorder != null) {
        boxBorder = this.application.getSession().getServer().serverBoxBorder;
    }

    if (boxBorder.contentEquals("1")) {
        llBorderBackground.setBackgroundResource(R.drawable.element_border);
    } else {
        llBorderBackground.setBackgroundColor(Color.TRANSPARENT);
    }

    if (useOpenSans) {
        poAuthor.setTypeface(opensans);
        poTimestamp.setTypeface(opensans);
        tvOnline.setTypeface(opensans);
    }

    if (useShading) {
        poAuthor.setShadowLayer(2, 0, 0, Color.parseColor("#66000000"));
        tvOnline.setShadowLayer(2, 0, 0, Color.parseColor("#66000000"));
    }

    final LinearLayout llPostBodyHolder = (LinearLayout) view.findViewById(R.id.message_body_holder);
    llPostBodyHolder.removeAllViews();

    final ImageView poAvatar = (ImageView) view.findViewById(R.id.message_avatar);

    if (boxColor != null && boxColor.contains("#") && boxColor.length() == 7) {
        final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame);
        postAvatarFrame.setColorFilter(Color.parseColor(boxColor));
    } else {
        final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame);
        postAvatarFrame.setVisibility(View.GONE);
    }

    if (message.isAuthorOnline()) {
        tvOnline.setText("ONLINE");
        tvOnline.setVisibility(View.VISIBLE);
    } else {
        tvOnline.setVisibility(View.GONE);
    }

    poAuthor.setText(message.getAuthor());
    poTimestamp.setText(DateTimeUtils.getTimeAgo(message.getTimestamp()));

    final String postContent = message.getBody();
    // TODO: add attachments
    BBCodeParser.parseCode(context, llPostBodyHolder, postContent, opensans, useOpenSans, useShading,
            new ArrayList<PostAttachment>(), fontSize, true, textColor, this.application);

    poAuthor.setTextColor(Color.parseColor(textColor));
    poTimestamp.setTextColor(Color.parseColor(textColor));

    if (currentAvatarSetting) {
        if (Net.isUrl(message.getAuthorAvatar())) {
            final String imageUrl = message.getAuthorAvatar();
            ImageLoader.getInstance().displayImage(imageUrl, poAvatar);
        } else {
            poAvatar.setImageResource(R.drawable.no_avatar);
        }
    } else {
        poAvatar.setVisibility(View.GONE);
    }
}

From source file:org.energyos.espi.datacustodian.oauth.EspiTokenEnhancer.java

@Transactional(rollbackFor = { javax.xml.bind.JAXBException.class }, noRollbackFor = {
        javax.persistence.NoResultException.class,
        org.springframework.dao.EmptyResultDataAccessException.class })
@Override/*from  www .j a va  2 s.c o m*/
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {

    DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);

    System.out.printf("EspiTokenEnhancer: OAuth2Request Parameters = %s\n",
            authentication.getOAuth2Request().getRequestParameters());

    System.out.printf("EspiTokenEnhancer: Authorities = %s\n", authentication.getAuthorities());

    String clientId = authentication.getOAuth2Request().getClientId();
    ApplicationInformation ai = null;

    // [mjb20150102] Allow REGISTRATION_xxxx and ADMIN_xxxx to use same
    // ApplicationInformation record
    String ci = clientId;
    String clientCredentialsScope = accessToken.getScope().toString();
    if (ci.indexOf("REGISTRATION_") != -1) {
        if (ci.substring(0, "REGISTRATION_".length()).equals("REGISTRATION_")) {
            ci = ci.substring("REGISTRATION_".length());
        }
    }
    if (ci.indexOf("_admin") != -1) {
        ci = ci.substring(0, ci.indexOf("_admin"));
    }

    // Confirm Application Information record exists for ClientID requesting
    // an access token
    try {
        ai = applicationInformationService.findByClientId(ci);

    } catch (NoResultException | EmptyResultDataAccessException e) {
        System.out.printf(
                "\nEspiTokenEnhancer: ApplicationInformation record not found!\n"
                        + "OAuth2Request Parameters = %s\n",
                authentication.getOAuth2Request().getRequestParameters() + " client_id = " + clientId);
        throw new AccessDeniedException(String.format("No client with requested id: %s", clientId));
    }

    Map<String, String> requestParameters = authentication.getOAuth2Request().getRequestParameters();
    String grantType = requestParameters.get(OAuth2Utils.GRANT_TYPE);
    grantType = grantType.toLowerCase();

    // Is this a "client_credentials" access token grant_type request?
    if (grantType.contentEquals("client_credentials")) {
        // Processing a "client_credentials" access token grant_type
        // request.

        // Reject a client_credentials request if Authority equals
        // "ROLE_USER"
        if (authentication.getAuthorities().toString().contains("[ROLE_USER]")) {
            throw new InvalidGrantException(String.format("Client Credentials not valid for ROLE_USER\n"));
        }

        // Create Authorization and add authorizationURI to /oath/token
        // response
        Authorization authorization = authorizationService.createAuthorization(null, result.getValue());
        result.getAdditionalInformation().put("authorizationURI",
                ai.getDataCustodianResourceEndpoint()
                        + Routes.DATA_CUSTODIAN_AUTHORIZATION.replace("espi/1_1/resource/", "")
                                .replace("{authorizationId}", authorization.getId().toString()));

        // Create Subscription
        Subscription subscription = subscriptionService.createSubscription(authentication);

        // Initialize Authorization record
        authorization.setThirdParty(authentication.getOAuth2Request().getClientId());
        authorization.setAccessToken(accessToken.getValue());
        authorization.setTokenType(accessToken.getTokenType());
        authorization.setExpiresIn((long) accessToken.getExpiresIn());
        authorization.setAuthorizedPeriod(new DateTimeInterval((long) 0, (long) 0));
        authorization.setPublishedPeriod(new DateTimeInterval((long) 0, (long) 0));

        if (accessToken.getRefreshToken() != null) {
            authorization.setRefreshToken(accessToken.getRefreshToken().toString());
        }

        // Remove "[" and "]" surrounding Scope in accessToken structure
        authorization.setScope(accessToken.getScope().toString().substring(1,
                (accessToken.getScope().toString().length() - 1)));

        // set the authorizationUri
        authorization.setAuthorizationURI(ai.getDataCustodianResourceEndpoint()
                + Routes.DATA_CUSTODIAN_AUTHORIZATION.replace("espi/1_1/resource/", "")
                        .replace("{authorizationId}", authorization.getId().toString()));

        // Determine resourceURI value based on Client's Role
        Set<String> role = AuthorityUtils.authorityListToSet(authentication.getAuthorities());

        if (role.contains("ROLE_DC_ADMIN")) {
            authorization.setResourceURI(ai.getDataCustodianResourceEndpoint() + "/");

        } else {
            if (role.contains("ROLE_TP_ADMIN")) {
                authorization.setResourceURI(ai.getDataCustodianResourceEndpoint()
                        + Routes.BATCH_BULK_MEMBER.replace("espi/1_1/resource/", "").replace("{bulkId}", "**"));

            } else {
                if (role.contains("ROLE_UL_ADMIN")) {
                    authorization
                            .setResourceURI(ai.getDataCustodianResourceEndpoint() + Routes.BATCH_UPLOAD_MY_DATA
                                    .replace("espi/1_1/resource/", "").replace("{retailCustomerId}", "**"));
                } else {
                    if (role.contains("ROLE_TP_REGISTRATION")) {
                        authorization.setResourceURI(ai.getDataCustodianResourceEndpoint()
                                + Routes.ROOT_APPLICATION_INFORMATION_MEMBER.replace("espi/1_1/resource/", "")
                                        .replace("{applicationInformationId}", ai.getId().toString()));
                    }
                }
            }
        }

        authorization.setApplicationInformation(applicationInformationService.findByClientId(ci));
        authorization.setRetailCustomer(retailCustomerService.findById((long) 0));
        authorization.setUpdated(new GregorianCalendar());
        authorization.setStatus("1"); // Set authorization record status as
        // "Active"
        authorization.setSubscription(subscription);
        authorizationService.merge(authorization);

        // Add resourceURI to access_token response
        result.getAdditionalInformation().put("resourceURI", authorization.getResourceURI());

        // Initialize Subscription record
        subscription.setAuthorization(authorization);
        subscription.setUpdated(new GregorianCalendar());
        subscriptionService.merge(subscription);

    } else if (grantType.contentEquals("authorization_code")) {

        try {
            // Is this a refresh_token grant_type request?
            Authorization authorization = authorizationService
                    .findByRefreshToken(result.getRefreshToken().getValue());

            // Yes, update access token
            authorization.setAccessToken(accessToken.getValue());
            authorizationService.merge(authorization);

            // Add ResourceURI and AuthorizationURI to access_token response
            result.getAdditionalInformation().put("resourceURI", authorization.getResourceURI());
            result.getAdditionalInformation().put("authorizationURI", authorization.getAuthorizationURI());

        } catch (NoResultException | EmptyResultDataAccessException e) {
            // No, process as initial access token request

            // Create Subscription and add resourceURI to /oath/token
            // response
            Subscription subscription = subscriptionService.createSubscription(authentication);
            result.getAdditionalInformation().put("resourceURI",
                    ai.getDataCustodianResourceEndpoint()
                            + Routes.BATCH_SUBSCRIPTION.replace("espi/1_1/resource/", "")
                                    .replace("{subscriptionId}", subscription.getId().toString()));

            // Create Authorization and add authorizationURI to /oath/token
            // response
            Authorization authorization = authorizationService.createAuthorization(subscription,
                    result.getValue());
            result.getAdditionalInformation().put("authorizationURI",
                    ai.getDataCustodianResourceEndpoint()
                            + Routes.DATA_CUSTODIAN_AUTHORIZATION.replace("espi/1_1/resource/", "")
                                    .replace("{authorizationId}", authorization.getId().toString()));

            // Update Data Custodian subscription structure
            subscription.setAuthorization(authorization);
            subscription.setUpdated(new GregorianCalendar());
            subscriptionService.merge(subscription);

            RetailCustomer retailCustomer = (RetailCustomer) authentication.getPrincipal();

            // link in the usage points associated with this subscription
            List<Long> usagePointIds = resourceService.findAllIdsByXPath(retailCustomer.getId(),
                    UsagePoint.class);
            Iterator<Long> it = usagePointIds.iterator();

            while (it.hasNext()) {
                UsagePoint up = resourceService.findById(it.next(), UsagePoint.class);
                up.setSubscription(subscription);
                resourceService.persist(up); // maybe not needed??
            }

            // Update Data Custodian authorization structure
            authorization.setApplicationInformation(applicationInformationService
                    .findByClientId(authentication.getOAuth2Request().getClientId()));
            authorization.setThirdParty(authentication.getOAuth2Request().getClientId());
            authorization.setRetailCustomer(retailCustomer);
            authorization.setAccessToken(accessToken.getValue());
            authorization.setTokenType(accessToken.getTokenType());
            authorization.setExpiresIn((long) accessToken.getExpiresIn());

            if (accessToken.getRefreshToken() != null) {
                authorization.setRefreshToken(accessToken.getRefreshToken().toString());
            }

            // Remove "[" and "]" surrounding Scope in accessToken structure
            authorization.setScope(accessToken.getScope().toString().substring(1,
                    (accessToken.getScope().toString().length() - 1)));
            authorization.setAuthorizationURI(ai.getDataCustodianResourceEndpoint()
                    + Routes.DATA_CUSTODIAN_AUTHORIZATION.replace("espi/1_1/resource/", "")
                            .replace("{authorizationId}", authorization.getId().toString()));
            authorization.setResourceURI(ai.getDataCustodianResourceEndpoint()
                    + Routes.BATCH_SUBSCRIPTION.replace("espi/1_1/resource/", "").replace("{subscriptionId}",
                            subscription.getId().toString()));
            authorization.setUpdated(new GregorianCalendar());
            authorization.setStatus("1"); // Set authorization record status
            // as "Active"
            authorization.setSubscription(subscription);
            authorization.setAuthorizedPeriod(new DateTimeInterval((long) 0, (long) 0));
            authorization.setPublishedPeriod(new DateTimeInterval((long) 0, (long) 0));

            authorizationService.merge(authorization);
        }

    } else {

        System.out.printf(
                "EspiTokenEnhancer: Invalid Grant_Type processed by Spring Security OAuth2 Framework:\n"
                        + "OAuth2Request Parameters = %s\n",
                authentication.getOAuth2Request().getRequestParameters());
        throw new AccessDeniedException(String.format("Unsupported ESPI OAuth2 grant_type"));
    }

    return result;
}

From source file:org.openhab.binding.pioneeravr.internal.ipcontrolprotocol.IpControl.java

/**
 * Sends to command to the receiver./*ww  w .j  a va2 s .  c  o m*/
 * It does not wait for a reply.
 * @param ipCmd the command to send.
 **/
public void sendCommand(String ipCmd) {
    logger.debug("Send command: {}", ipCmd);

    StringBuilder sb = new StringBuilder();
    sb.append(ipCmd);
    sb.append((char) '\r');
    sendCommand(sb, false, retryCount);

    // when comamnd is power on, send it twice. first wakes up receiver
    if (ipCmd.contentEquals(IpControlCommand.POWER_ON.getCommand())) {

        // delay and repeat command after 100ms - accoring to Pioneer protocol spec
        try {
            TimeUnit.MILLISECONDS.sleep(100); // wait 100ms to power on
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
        sendCommand(sb, false, retryCount);
    }
}

From source file:com.openarc.nirmal.nestle.LoginActivity.java

private boolean isLastLoginDate() {
    String previousDate = sharedPreferences.getString(SharedPreferencesName.previousLoginDate, "");
    if (!previousDate.contentEquals("")) {
        String today = Session.getSession().getStingDate(Calendar.getInstance().getTime());
        return today.contentEquals(previousDate);
    } else {//from ww  w.  java 2s  .c  om
        return false;
    }
}