Example usage for java.lang Integer getInteger

List of usage examples for java.lang Integer getInteger

Introduction

In this page you can find the example usage for java.lang Integer getInteger.

Prototype

public static Integer getInteger(String nm) 

Source Link

Document

Determines the integer value of the system property with the specified name.

Usage

From source file:org.lockss.test.LockssTestCase.java

public LockssTestCase() {
    super();//from  ww w  .ja v  a 2  s. c om
    Integer timeout = Integer.getInteger("org.lockss.test.timeout.shouldnt");
    if (timeout != null) {
        TIMEOUT_SHOULDNT = timeout.intValue();
    }
}

From source file:com.smash.revolance.ui.cmdline.Commands.java

private int execStopCmd(File workingDir, String[] opts) {
    try {/*from w  w  w. j a  va2 s. c om*/
        System.out.println("Stopping server");
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(
                "http://localhost:" + Integer.getInteger("port").intValue() + "/ui-monitoring-server/shutdown");
        HttpResponse response = client.execute(request);
        if (response.getStatusLine().getStatusCode() != 200) {
            System.out.println("Stopping server [Done]");
            return 0;
        } else {
            System.err.println("Stopping server [Failed]");
            return 1;
        }
    } catch (IOException e) {
        return 2;
    }
}

From source file:org.apache.webdav.lib.methods.PollMethod.java

public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
        throws IOException, HttpException {
    int status = getStatusLine().getStatusCode();

    if (status == HttpStatus.SC_MULTI_STATUS) {
        parseXMLResponse(input);/*w w w  .  j av a 2  s.  co  m*/
        NodeList list = getResponseDocument().getDocumentElement().getElementsByTagNameNS("DAV:", "response");

        for (int i = 0; i < list.getLength(); i++) {
            Element e = (Element) list.item(i);

            NodeList s = e.getElementsByTagNameNS("DAV:", "status");
            if (s.getLength() > 0) {
                Element response = ((Element) (s.item(0)).getParentNode());
                String statusText = DOMUtils.getTextValue(s.item(0));
                if (statusText.indexOf(" 200 ") != -1) {
                    // polled subscriptions for which *AN* event is fired
                    NodeList p = response.getElementsByTagNameNS(EXCHANGE_NS, "subscriptionID");
                    if (p.getLength() > 0) {
                        NodeList li = ((Element) p.item(0)).getElementsByTagName("li");
                        for (int l = 0; l < li.getLength(); ++l) {
                            String id = DOMUtils.getTextValue(li.item(i));
                            this.subscriptionsWithEvents.add(Integer.getInteger(id));
                        }
                    }
                } else if (statusText.indexOf(" 204 ") != -1) {
                    // polled subscriptions for which *NO* event is fired
                    NodeList p = response.getElementsByTagNameNS(EXCHANGE_NS, "subscriptionID");
                    if (p.getLength() > 0) {
                        NodeList li = ((Element) p.item(0)).getElementsByTagName("li");
                        for (int l = 0; l < li.getLength(); ++l) {
                            String id = DOMUtils.getTextValue(li.item(i));
                            this.subscriptionsWithoutEvents.add(Integer.getInteger(id));
                        }
                    }
                }
            }
        }
    }
}

From source file:com.opengsn.services.client.CloudManagerClient.java

/**
 * //  w ww  . j  ava  2 s  .c  o  m
 *   @param args
 *            String[] - resource id, new priority number, resource id2, priority num 2, etc.
 */
public void overrideHostPriories(String[] args) {

    PrioritiesList pList = new PrioritiesList();

    for (int i = 0; i < args.length; i += 2) {
        IdPriority priority = new IdPriority();
        priority.setId(args[i]);
        priority.setPriority(Integer.getInteger(args[i + 1]));
        pList.getPriorities().add(priority);
    }

    OverrideMapType overrideMap = new OverrideMapType();
    overrideMap.setPrioritiesList(pList);

    port.overrideHostPriorities(overrideMap);
}

From source file:com.ericsson.eiffel.remrem.publish.config.RabbitMqPropertiesConfig.java

/***
 * Writes RabbitMq catalina properties to RabbitMq instances properties map object and set Generate server properties.
 * //from   www  .ja  v  a2  s  . c  o m
 * @param map
 *            RabbitMq instances map object.
 */
private void populateConfigurationsBasedOnCatalinaProperties(Map<String, Object> map) {
    final String jasyptSecretPassword = (String) map.get("jasypt.encryptor.password");
    for (Entry<String, Object> entry : map.entrySet()) {
        final String key = entry.getKey();
        if (key.contains("rabbitmq")) {
            String protocol = key.split("\\.")[0];
            if (rabbitMqPropertiesMap.get(protocol) == null) {
                rabbitMqPropertiesMap.put(protocol, new RabbitMqProperties());
            }
            if (key.contains("rabbitmq.host")) {
                rabbitMqPropertiesMap.get(protocol).setHost(entry.getValue().toString());
            } else if (key.contains("rabbitmq.port")) {
                rabbitMqPropertiesMap.get(protocol).setPort(Integer.getInteger(entry.getValue().toString()));
            } else if (key.contains("rabbitmq.username")) {
                rabbitMqPropertiesMap.get(protocol).setUsername(entry.getValue().toString());
            } else if (key.contains("rabbitmq.password")) {
                rabbitMqPropertiesMap.get(protocol).setPassword(
                        DecryptionUtils.decryptString(entry.getValue().toString(), jasyptSecretPassword));
            } else if (key.contains("rabbitmq.tls")) {
                rabbitMqPropertiesMap.get(protocol).setTlsVer(entry.getValue().toString());
            } else if (key.contains("rabbitmq.exchangeName")) {
                rabbitMqPropertiesMap.get(protocol).setExchangeName(entry.getValue().toString());
            } else if (key.contains("rabbitmq.domainId")) {
                rabbitMqPropertiesMap.get(protocol).setDomainId(entry.getValue().toString());
            } else if (key.contains("rabbitmq.createExchangeIfNotExisting")) {
                rabbitMqPropertiesMap.get(protocol)
                        .setCreateExchangeIfNotExisting(Boolean.parseBoolean(entry.getValue().toString()));
            }
        }
    }
    final String generateServerUri = (String) map.get(GENERATE_SERVER_URI);
    generateURLTemplate.setGenerateServerUri(generateServerUri);

    final String generateServerPath = (String) map.get(GENERATE_SERVER_PATH);
    generateURLTemplate.setGenerateServerPath(generateServerPath);
}

From source file:com.quinsoft.zeidon.objectdefinition.ViewOd.java

@Override
public void setAttribute(PortableFileReader reader) {
    if (reader.getAttributeName().equals("NAME")) {
        if (!reader.getAttributeValue().equalsIgnoreCase(name))
            throw new ZeidonException("Name of object from XOD ('%s') doesn't match OD name",
                    reader.getAttributeValue());

        // Override the name used when this object was being created with the one from the .xod file.
        // We need to do this because names are case-insensitive and the user may have used a different
        // case than the one from the file.
        name = reader.getAttributeValue().intern();
    } else if (reader.getAttributeName().equals("ER_DATE")) {
        erDate = reader.getAttributeValue().intern();
    } else if (reader.getAttributeName().equals("DATABASE") || reader.getAttributeName().equals("DFT_DBNAME")) {
        database = reader.getAttributeValue().intern();
    } else if (reader.getAttributeName().equals("DBH_Data")) {
        // We don't actually use DBH_Data in JOE but this code is here because we need to
        // read past the blob data.
        int lth = Integer.parseInt(reader.getAttributeValue());
        byte[] buffer = new byte[lth];
        try {/*from w  w w  . j  a v  a2  s .  c o  m*/
            reader.getStreamReader().read(buffer, lth);
        } catch (Throwable e) {
            throw ZeidonException.wrapException(e);
        }
    }
    if (reader.getAttributeName().equals("GKHANDLER")) {
        genkeyHandler = reader.getAttributeValue().intern();
    } else if (reader.getAttributeName().equals("LOCK")) {
        Integer level = Integer.getInteger(reader.getAttributeValue());
        lockingLevel = LockingLevel.lookup(level);
    } else if (reader.getAttributeName().equals("OCEOPER")) {
        constraintOper = reader.getAttributeValue().intern();
    } else if (reader.getAttributeName().equals("OCACT")) {
        activateConstraint = reader.getAttributeValue().startsWith("Y");
    } else if (reader.getAttributeName().equals("OCCOM")) {
        commitConstraint = reader.getAttributeValue().startsWith("Y");
    } else if (reader.getAttributeName().equals("OCSRCTYPE")) {
        sourceFileType = SourceFileType.parse(reader.getAttributeValue());
    }
}

From source file:chat.viska.xmpp.plugins.webrtc.WebRtcPlugin.java

private void consumeIceCandidate(@Nonnull final Element iceCandidateElement, @Nonnull final String id,
        final boolean creating) {
    final Node sdpElement = Observable.fromIterable(DomUtils.convertToList(iceCandidateElement.getChildNodes()))
            .filter(it -> "sdp".equals(it.getLocalName())).firstElement().blockingGet();
    final String sdp = sdpElement == null ? "" : convertSdpElementsToString(sdpElement);
    this.eventStream
            .onNext(new IceCandidateReceivedEvent(
                    new IceCandidate(iceCandidateElement.getAttribute("sdpMid"),
                            Integer.getInteger(iceCandidateElement.getAttribute("sdpMLineIndex")), sdp),
                    id, creating));/*from  www  .j  a va2  s  .co m*/
}

From source file:org.wso2.carbon.apimgt.gateway.mediators.RegularExpressionProtector.java

/**
 * This method returns true if the request payload size exceeds the system property
 * 'payloadSizeLimitForRegexThreatProtector' value (in KB) defined. If this system property is not defined, this
 * check won't be done.//from  w ww  .  ja va 2s  .  co m
 *
 * @param messageContext contains the message properties of the relevant API request which was
 *                       enabled the regexValidator message mediation in flow.
 * @return true if the payload size has exceeded the defined value in system property
 */
private boolean isPayloadSizeExceeded(MessageContext messageContext) {
    // payloadSizeLimit is in KB
    Integer payloadSizeLimit = Integer
            .getInteger(APIMgtGatewayConstants.PAYLOAD_SIZE_LIMIT_FOR_REGEX_TREAT_PROTECTOR);
    if (payloadSizeLimit == null) {
        return false;
    }
    long requestPayloadSize = 0;
    org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext)
            .getAxis2MessageContext();
    Map headers = (Map) axis2MC.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    String contentLength = (String) headers.get(HttpHeaders.CONTENT_LENGTH);
    if (contentLength != null) {
        requestPayloadSize = Integer.parseInt(contentLength);
    } else { //When chunking is enabled
        SOAPEnvelope env = messageContext.getEnvelope();
        if (env != null) {
            SOAPBody soapbody = env.getBody();
            if (soapbody != null) {
                byte[] size = soapbody.toString().getBytes(Charset.defaultCharset());
                requestPayloadSize = size.length;
            }
        }
    }
    if (requestPayloadSize > payloadSizeLimit * 1024) {
        GatewayUtils.handleThreat(messageContext, APIMgtGatewayConstants.HTTP_SC_CODE,
                "Exceeded Request Payload "
                        + "size limit allowed to be used with the enabledCheckBody option of Regular Expression Threat "
                        + "Protector mediator");
        return true;
    } else {
        return false;
    }
}

From source file:org.apache.hadoop.mpich.appmaster.pmi.PMIClientCommandHandler.java

private List<String> onGetByIdx(Map<String, String> kvs) {
    String kvsName = kvs.get("kvsname");
    KVStore kvStore = this.manager.getKvStore(kvsName);
    PMIResponseBuilder responseBuilder = new PMIResponseBuilder().append("cmd", "getbyidx_results");
    if (kvStore != null) {
        Integer idx = Integer.getInteger(kvs.get("idx"));
        KVPair result = kvStore.getKVPairByIdx(idx);
        if (result != null) {
            responseBuilder.append("rc", "0").append("nextidx", Integer.toString(idx + 1))
                    .append("key", result.getKey()).append("val", result.getValue());
        } else {/*from  w ww. j  a v a2s.  c  om*/
            responseBuilder.append("rc", "-1").append("reason", "no_more_keyvals");
        }
    } else {
        responseBuilder.append("rc", "-1").append("reason", "kvs_" + kvsName + "_not_found");
    }
    List<String> response = new ArrayList<String>();
    response.add(responseBuilder.build());
    return response;
}

From source file:org.opennms.features.newts.converter.eventd.EventdStresser.java

private static void processSystemProperties() throws IllegalArgumentException, NumberFormatException {

    String property = System.getProperty(PROPERTY_DELETE_ALL_EVENTS);
    if (property != null) {
        m_deleteAllEvents = Boolean.valueOf(property);
        System.out.println("Using delete all events flag: " + m_deleteAllEvents);
    }/* ww w.  j a  v  a 2s .  c om*/

    property = System.getProperty(PROPERTY_DELETE_TEST_EVENTS);
    if (property != null) {
        m_deleteTestEvents = Boolean.valueOf(property);
        System.out.println("Using delete test events flag: " + m_deleteTestEvents);
    }

    property = System.getProperty(PROPERTY_AGENT_IPADDRESS);
    if (property != null) {
        try {
            m_agentAddress = InetAddress.getByName(property);
            System.out.println("Using agent address: " + m_agentAddress);
        } catch (UnknownHostException e) {
            throw new IllegalArgumentException("Invalid Agent address.", e);
        }
    }

    property = System.getProperty(PROPERTY_TRAP_SINK);
    if (property != null) {
        try {
            m_trapSink = InetAddress.getByName(property);
            System.out.println("Using trap sink: " + m_trapSink);
        } catch (UnknownHostException e) {
            throw new IllegalArgumentException("Invalid Destination address.", e);
        }
    }

    property = System.getProperty(PROPERTY_TRAP_PORT);
    if (property != null) {
        m_trapPort = Integer.getInteger(PROPERTY_TRAP_PORT);
        System.out.println("Using Trap port: " + m_trapPort);
    }

    property = System.getProperty(PROPERTY_TRAP_COMMUNITY);
    if (property != null) {
        m_trapCommunity = property;
        System.out.println("Using Trap Community name: " + m_trapCommunity);
    }

    property = System.getProperty(PROPERTY_TRAP_COUNT);
    if (property != null) {
        m_trapCount = Integer.getInteger(PROPERTY_TRAP_COUNT);
        m_batchSize = m_trapCount;
        m_batchCount = 1;
        System.out.println("Using Trap count: " + m_trapCount);
    }

    property = System.getProperty(PROPERTY_TRAP_RATE);
    if (property != null) {
        m_trapRate = Integer.getInteger(PROPERTY_TRAP_RATE).doubleValue();
        System.out.println("Using Trap rate: " + m_trapRate);
    }

    property = System.getProperty(PROPERTY_BATCH_DELAY);
    if (property != null) {
        m_batchDelay = Integer.getInteger(PROPERTY_BATCH_DELAY);
        System.out.println("Using batch delay: " + m_batchDelay);
    }

    property = System.getProperty(PROPERTY_BATCH_SIZE);
    if (property != null) {
        m_batchSize = Integer.getInteger(PROPERTY_BATCH_SIZE);
        System.out.println("Using batch size: " + m_batchSize);
    }

    property = System.getProperty(PROPERTY_PERSIST_WAIT);
    if (property != null) {
        m_persistWait = Integer.getInteger(PROPERTY_PERSIST_WAIT);
        System.out.println("Using Event persistence wait period of: " + m_persistWait);
    }

    m_batchCount = m_trapCount.intValue() / m_batchSize.intValue();
    System.out.println("Using batch count: " + m_batchCount);

    property = System.getProperty(PROPERTY_DB_SVR);
    if (property != null) {
        m_dbSvr = property;
    }

    property = System.getProperty(PROPERTY_DB_NAME);
    if (property != null) {
        m_dbName = property;
    }

    property = System.getProperty(PROPERTY_DB_USER);
    if (property != null) {
        m_dbUser = property;
    }

    property = System.getProperty(PROPERTY_DB_PW);
    if (property != null) {
        m_dbPass = property;
    }

}