Example usage for org.apache.commons.lang StringUtils abbreviate

List of usage examples for org.apache.commons.lang StringUtils abbreviate

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils abbreviate.

Prototype

public static String abbreviate(String str, int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:org.ojbc.bundles.connectors.OJBWebApplicationConnectorIntTest.java

@Test
public void testIdentityBasedAccessControl() throws Exception {

    //Add SAML token to request call
    Element samlToken = SAMLTokenUtils.createStaticAssertionAsElement(
            "http://ojbc.org/ADS/AssertionDelegationService",
            SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS, SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1,
            true, true, null);/* w  w  w. j  av  a  2  s. c o  m*/

    String federatedQueryID = returnFederatedQueryGUID();

    //Invoke the service
    String response = identityBasedAccessControlRequestProcessor.invokeAccessControlRequest(federatedQueryID,
            samlToken, policyAccessControlResourceURI);

    log.info("Body recieved by Service (truncated): " + StringUtils.abbreviate(response, 503));

    Assert.assertNotNull(response);
}

From source file:org.ojbc.bundles.connectors.OJBWebApplicationConnectorIntTest.java

@Test
public void testPolicyAcknowledgementRecordingService() throws Exception {
    Map<SamlAttribute, String> customAttributes = new HashMap<SamlAttribute, String>();
    customAttributes.put(SamlAttribute.FederationId, "");

    //Add SAML token to request call
    Element samlToken = SAMLTokenUtils.createStaticAssertionAsElement(
            "http://ojbc.org/ADS/AssertionDelegationService",
            SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS, SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1,
            true, true, customAttributes);

    String federatedQueryID = returnFederatedQueryGUID();

    //Invoke the service
    //Invoke the service
    String response = policyAcknowledgingRequestProcessor
            .invokePolicyAcknowledgementRecordingRequest(federatedQueryID, samlToken);

    log.info("Body recieved by Service (truncated): " + StringUtils.abbreviate(response, 503));

    Assert.assertNotNull(response);/*from   w w  w .j a v a2  s. c o  m*/
}

From source file:org.ojbc.processor.RequestResponseProcessor.java

/**
 * This method is called by the camel response listener route to update the map with the reply 
 * /*from w ww .j  a  v  a 2  s . c o m*/
 * @param response
 * @param federatedQueryID
 */
public final void updateMapWithResponse(@Body String response,
        @Header("federatedQueryRequestGUID") String federatedQueryID) {
    log.debug("Messaage ID: " + federatedQueryID);

    if (response.length() > 500) {
        log.debug("Here is the response (truncated): " + StringUtils.abbreviate(response, 503));
    } else {
        log.debug("Here is the response: " + response);
    }

    requestResponseMap.put(federatedQueryID, response);
}

From source file:org.ojbc.processor.RequestResponseProcessor.java

/**
 * This method is called by the camel response listener route to update the map with the reply 
 * /*from www  .  j ava  2 s  .c  o m*/
 * @param response
 * @param federatedQueryID
 */
public final void updateMapWithResponseExchange(Exchange exchange, @Body String response,
        @Header("federatedQueryRequestGUID") String federatedQueryID) {
    log.debug("Messaage ID: " + federatedQueryID);

    if (response.length() > 500) {
        log.debug("Here is the response (truncated): " + StringUtils.abbreviate(response, 503));
    } else {
        log.debug("Here is the response: " + response);
    }

    requestResponseMap.put(federatedQueryID, exchange);
}

From source file:org.onosproject.drivers.bti.NetSnmpDeviceDescriptor.java

private DeviceDescription populateDescription(ISnmpSession session, Device device) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY, session.getAddress().getHostAddress());
    try {//  w  w w. j a  v  a2 s .c om
        session.walkDevice(networkDevice,
                Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(System.class)));

        com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree = (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System) networkDevice
                .getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap()
                        .get(com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
        if (systemTree != null) {
            // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
            // so cut it here until supported in prop displayer
            String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
            return new DefaultDeviceDescription(device.id().uri(), device.type(), manufacturer, UNKNOWN,
                    UNKNOWN, UNKNOWN, device.chassisId(), (SparseAnnotations) device.annotations());
        }
    } catch (IOException ex) {
        throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
    }
    return null;
}

From source file:org.onosproject.provider.snmp.device.impl.NetSnmpDeviceDescriptionProvider.java

@Override
public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY, session.getAddress().getHostAddress());
    try {//from   w w  w  . j  a  va  2  s  .co m
        session.walkDevice(networkDevice, Arrays.asList(new OID[] { CLASS_REGISTRY.getClassToOidMap()
                .get(com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class) }));

        com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree = (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System) networkDevice
                .getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap()
                        .get(com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
        if (systemTree != null) {
            // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
            // so cut it here until supported in prop displayer
            String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
            return new DefaultDeviceDescription(description.deviceUri(), description.type(), manufacturer,
                    UNKNOWN, UNKNOWN, UNKNOWN, description.chassisId(), description.annotations());
        }
    } catch (IOException ex) {
        log.error("Error reading details for device {}.", session.getAddress(), ex);
    }
    return description;
}

From source file:org.openbel.framework.core.kam.JdbcKAMLoaderImpl.java

/**
 * {@inheritDoc}//from  ww w.  j  av  a  2s.  c  o  m
 */
@Override
public void loadAnnotationDefinitions(AnnotationDefinitionTable adt) throws SQLException {
    PreparedStatement adps = getPreparedStatement(ANNOTATION_DEFINITION_SQL);

    for (Map.Entry<Integer, TableAnnotationDefinition> ade : adt.getIndexDefinition().entrySet()) {
        TableAnnotationDefinition ad = ade.getValue();
        adps.setInt(1, (ade.getKey() + 1));
        adps.setString(2, ad.getName());

        if (AnnotationDefinitionTable.URL_ANNOTATION_TYPE_ID == ad.getAnnotationType()) {
            adps.setNull(3, Types.VARCHAR);
            adps.setNull(4, Types.VARCHAR);
        } else {
            adps.setString(3, StringUtils.abbreviate(ad.getDescription(), MAX_MEDIUM_VARCHAR_LENGTH));
            adps.setString(4, StringUtils.abbreviate(ad.getUsage(), MAX_MEDIUM_VARCHAR_LENGTH));
        }

        final int oid;
        final String domain = ad.getAnnotationDomain();
        final Integer objectId = valueIndexMap.get(domain);
        if (objectId != null) {
            oid = objectId;
        } else {
            oid = saveObject(1, domain);
            valueIndexMap.put(domain, oid);
        }

        adps.setInt(5, oid);
        adps.setInt(6, ad.getAnnotationType());
        adps.addBatch();
    }

    adps.executeBatch();

    // associate annotate definitions to documents
    PreparedStatement dadmps = getPreparedStatement(DOCUMENT_ANNOTATION_DEFINITION_MAP_SQL);
    Map<Integer, Set<Integer>> dadm = adt.getDocumentAnnotationDefinitions();

    Set<Entry<Integer, Set<Integer>>> entries = dadm.entrySet();
    for (final Entry<Integer, Set<Integer>> entry : entries) {
        final Integer key = entry.getKey();
        for (final Integer adid : entry.getValue()) {
            dadmps.setInt(1, (key + 1));
            dadmps.setInt(2, (adid + 1));
            dadmps.addBatch();
        }
        dadmps.executeBatch();
    }
}

From source file:org.opencastproject.comments.Comment.java

@Override
public String toString() {
    return "Comment:" + id + "|" + StringUtils.abbreviate(text, 25);
}

From source file:org.opencastproject.comments.CommentReply.java

@Override
public String toString() {
    return "Comment reply:" + id + "|" + StringUtils.abbreviate(text, 25);
}

From source file:org.openengsb.connector.email.internal.EmailNotifier.java

@Override
public void notify(Notification notification) {
    log.info(String.format("notifying %s via email...", notification.getRecipient()));
    log.info("Subject: " + notification.getSubject());
    log.info("Message: " + StringUtils.abbreviate(notification.getMessage(), 200));
    mailAbstraction.send(properties, notification.getSubject(), notification.getMessage(),
            notification.getRecipient());
    log.info("mail has been sent");
}