List of usage examples for java.math BigInteger toString
public String toString()
From source file:com.facebook.infrastructure.service.StorageService.java
public void updateToken(BigInteger token) throws IOException { /* update the token on disk */ SystemTable.openSystemTable(SystemTable.name_).updateToken(token); /* Update the storageMetadata cache */ storageMetadata_.setStorageId(token); /* Update the token maps */ /* Get the old token. This needs to be removed. */ tokenMetadata_.update(token, StorageService.tcpAddr_); /* Gossip this new token for the local storage instance */ Gossiper.instance().addApplicationState(StorageService.nodeId_, new ApplicationState(token.toString())); }
From source file:org.apache.juddi.validation.ValidateReplication.java
public void validateGetChangeRecords(String requestingNode, HighWaterMarkVectorType changesAlreadySeen, BigInteger responseLimitCount, HighWaterMarkVectorType responseLimitVector, ReplicationConfiguration FetchEdges, WebServiceContext ctx) throws DispositionReportFaultMessage { //TODO//from ww w . j a va 2s. c o m if (requestingNode == null || requestingNode.trim().equalsIgnoreCase("")) { //requestingNode: The requestingNode element provides the identity of the calling node. //This is the unique key for the calling node and SHOULD be specified within the Replication Configuration Structure. throw new FatalErrorException(new ErrorMessage("errors.replication.nodeNotSpecified")); } //if (!ContainsNode(requestingNode, FetchEdges)) { // throw new FatalErrorException(new ErrorMessage("errors.replication.unknownNode")); //} if (changesAlreadySeen != null) { // changesAlreadySeen: The changesAlreadySeen element, if present, indicates changes from each //node that the requestor has successfully processed, and thus which should not be resent, if possible. //no validation needed? } if (responseLimitCount != null && responseLimitVector != null) { throw new FatalErrorException(new ErrorMessage("errors.replication.bothLimitsSpecified")); } if (responseLimitCount != null) { //can't be 0 since 0 is banned as being a change record id if (responseLimitCount.longValue() <= 0) { throw new FatalErrorException( new ErrorMessage("errors.replication.negativeLimit", responseLimitCount.toString())); } } if (responseLimitVector != null) { for (int i = 0; i < responseLimitVector.getHighWaterMark().size(); i++) { if (responseLimitVector.getHighWaterMark().get(i).getOriginatingUSN() == null || responseLimitVector.getHighWaterMark().get(i).getOriginatingUSN() <= 0) { throw new FatalErrorException(new ErrorMessage("errors.replication.limitVectorNull")); } if (responseLimitVector.getHighWaterMark().get(i).getNodeID() == null || responseLimitVector.getHighWaterMark().get(i).getNodeID().trim().equalsIgnoreCase("")) { throw new FatalErrorException(new ErrorMessage("errors.replication.limitVectorNoNode")); } } } /** * responseLimitCount or responseLimitVector: A caller MAY place * an upper bound on the number of change records he wishes to * receive in response to this message by either providing a * integer responseLimitCount, or, using responseLimitVector, * indicating for each node in the graph the first change * originating there that he does not wish to be returned. * */ }
From source file:org.jboss.bqt.client.xml.XMLQueryVisitationStrategy.java
/** * Produce an XML message for an instance of the BigInteger. * <br>//from ww w . j a va2 s. c o m * @param object the instance for which the message is to be produced. * @param parent the XML element that is to be the parent of the produced XML message. * @return the root element of the XML segment that was produced. * @exception JDOMException if there is an error producing the message. */ private Element produceMsg(BigInteger object, Element parent) throws JDOMException { // ---------------------- // Create the BigInteger element ... // ---------------------- Element bigIntegerElement = new Element(TagNames.Elements.BIGINTEGER); bigIntegerElement.setText(object.toString()); if (parent != null) { bigIntegerElement = parent.addContent(bigIntegerElement); } return bigIntegerElement; }
From source file:org.estatio.api.Api.java
private LeaseTerm putLeaseTerm(final String leaseReference, final String unitReference, final BigInteger itemSequence, final String itemType, final LocalDate itemStartDate, final LocalDate startDate, final LocalDate endDate, final BigInteger sequence, final String statusStr) { final Lease lease = fetchLease(leaseReference); final Unit unit; if (unitReference != null) { unit = units.findUnitByReference(unitReference); if (unitReference != null && unit == null) { throw new ApplicationException(String.format("Unit with reference %s not found.", unitReference)); }/* www . j a v a2 s . c om*/ } final LeaseItemType leaseItemType = fetchLeaseItemType(itemType); final LeaseItem item = lease.findItem(leaseItemType, itemStartDate, itemSequence); if (item == null) { throw new ApplicationException( String.format("LeaseItem with reference %1$s, %2$s, %3$s, %4$s not found.", leaseReference, leaseItemType.toString(), itemStartDate.toString(), itemSequence.toString())); } LeaseTerm term = item.findTermWithSequence(sequence); if (term == null) { if (sequence.equals(BigInteger.ONE)) { term = item.newTerm(startDate, endDate); } else { final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE)); term = previousTerm.createNext(startDate, endDate); } term.setSequence(sequence); } term.setStatus(org.estatio.dom.lease.LeaseTermStatus.valueOf(statusStr)); return term; }
From source file:eu.europa.ec.markt.tlmanager.core.validation.Validation.java
private void validateSimple(NODENAMES name, String field, Object type, TYPEFORMATS typeFormat, Object parent) { boolean fieldIsEmpty = false; if (type == null) { fieldIsEmpty = true;/*from w w w.j a v a2 s. c o m*/ } else if (type instanceof String && StringUtils.isBlank((String) type)) { fieldIsEmpty = true; } else if (typeFormat.equals(TYPEFORMATS.TEXT)) { String str = (String) type; if (str.isEmpty() || str.equals(Util.DEFAULT_NO_SELECTION_ENTRY)) { fieldIsEmpty = true; } } else if (typeFormat.equals(TYPEFORMATS.NUMBER)) { if (type instanceof BigInteger) { BigInteger big = (BigInteger) type; if (big.toString().isEmpty()) { fieldIsEmpty = true; } } } else if (typeFormat.equals(TYPEFORMATS.URL)) { // nop } else if (typeFormat.equals(TYPEFORMATS.DATE)) { // nop } if (fieldIsEmpty) { logger.error(logger.getEmptyMessage(name.toString(), field), parent); } }
From source file:com.flexive.core.storage.genericSQL.GenericTreeStorage.java
protected void setNodeBounds(PreparedStatement stmt, int index, BigInteger value) throws SQLException { // Postgres 8.x does not perform automatic conversion from String (unlike other DBMS) stmt.setBigDecimal(index, new BigDecimal(value.toString())); }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8UInt64DefTable.java
public void createUInt64Def(MSSBamAuthorization Authorization, MSSBamUInt64DefBuff Buff) { final String S_ProcName = "createUInt64Def "; try {/*ww w. ja v a 2 s .c o m*/ Connection cnx = schema.getCnx(); long Id = Buff.getRequiredId(); BigInteger InitValue = Buff.getOptionalInitValue(); BigInteger DefaultValue = Buff.getOptionalDefaultValue(); BigInteger MinValue = Buff.getOptionalMinValue(); BigInteger MaxValue = Buff.getOptionalMaxValue(); BigInteger NullValue = Buff.getOptionalNullValue(); BigInteger UnknownValue = Buff.getOptionalUnknownValue(); String sql = "INSERT INTO mssbam110.uint64_def( " + "id, " + "initval, " + "defval, " + "minval, " + "maxval, " + "nullvalue, " + "unknownval" + " )" + "VALUES ( " + Id + ", " + ((InitValue == null) ? "null" : InitValue.toString()) + ", " + ((DefaultValue == null) ? "null" : DefaultValue.toString()) + ", " + ((MinValue == null) ? "null" : MinValue.toString()) + ", " + ((MaxValue == null) ? "null" : MaxValue.toString()) + ", " + ((NullValue == null) ? "null" : NullValue.toString()) + ", " + ((UnknownValue == null) ? "null" : UnknownValue.toString()) + " )"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); int rowsAffected = stmt.executeUpdate(sql); if (rowsAffected != 1) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 row to be affected by insert, not " + rowsAffected); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } }
From source file:org.ejbca.core.protocol.ocsp.OCSPUnidClient.java
/** * @param serialNr serial number of the certificate to verify * @param cacert issuer of the certificate to verify * @param useGet if true GET will be used instead of POST as HTTP method * @return response can contain and an error code but the fnr is allways null, never returns null. * @throws OCSPException /* w ww. j a va 2 s . co m*/ * @throws IOException * @throws OperatorCreationException if Signer couldn't be created * @throws KeyStoreException * @throws NoSuchAlgorithmException * @throws CertificateException * @throws KeyManagementException * @throws UnrecoverableKeyException */ public OCSPUnidResponse lookup(BigInteger serialNr, X509Certificate cacert, boolean useGet) throws OCSPException, IOException, OperatorCreationException, UnrecoverableKeyException, KeyManagementException, CertificateException, NoSuchAlgorithmException, KeyStoreException { if (this.httpReqPath == null) { // If we didn't pass a url to the constructor and the cert does not have the URL, we will fail... OCSPUnidResponse ret = new OCSPUnidResponse(); ret.setErrorCode(OCSPUnidResponse.ERROR_NO_OCSP_URI); return ret; } final OCSPReqBuilder gen = new OCSPReqBuilder(); final CertificateID certId = new JcaCertificateID(SHA1DigestCalculator.buildSha1Instance(), (X509Certificate) cacert, serialNr); gen.addRequest(certId); if (!useGet) { // Add a nonce to the request gen.setRequestExtensions(this.extensions); } final OCSPReq req; if (this.signKey != null) { final X509Certificate localCertChain[] = this.certChain != null ? this.certChain : new X509Certificate[] { (X509Certificate) cacert }; final JcaX509CertificateHolder[] certificateHolderChain = CertTools .convertToX509CertificateHolder(localCertChain); gen.setRequestorName(certificateHolderChain[0].getSubject()); req = gen.build( new BufferingContentSigner(new JcaContentSignerBuilder("SHA1withRSA") .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(this.signKey), 20480), certificateHolderChain); } else { req = gen.build(); } // write request if directory exists. File ocspReqDir = new File(requestDirectory); if (ocspReqDir.isDirectory()) { OutputStream os = new FileOutputStream(new File(ocspReqDir, serialNr.toString())); os.write(req.getEncoded()); os.close(); } // Send the request and receive a BasicResponse return sendOCSPRequest(req.getEncoded(), cacert, useGet); }
From source file:org.opendaylight.netvirt.elan.utils.ElanUtils.java
/** * Builds the list of actions to be taken when sending the packet over an * external VxLan tunnel interface, such as stamping the VNI on the VxLAN * header, setting the vlanId if it proceeds and output the packet over the * right port./*w w w . j a va2s . c om*/ * * @param srcDpnId * Dpn where the tunnelInterface is located * @param torNode * NodeId of the ExternalDevice where the packet must be sent to. * @param vni * Vni to be stamped on the VxLAN Header. * @return the external itm egress action */ public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, NodeId torNode, long vni) { List<Action> result = Collections.emptyList(); GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder() .setDestinationNode(torNode.getValue()).setSourceNode(srcDpnId.toString()) .setTunnelType(TunnelTypeVxlan.class).build(); Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService .getExternalTunnelInterfaceName(input); try { if (output.get().isSuccessful()) { GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult(); String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName(); LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName); result = buildTunnelItmEgressActions(tunnelIfaceName, vni); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error in RPC call getTunnelInterfaceName {}", e); } return result; }
From source file:org.nordapp.web.servlet.IOServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {/*from w w w. j av a 2 s. c om*/ //@SuppressWarnings("unused") final String mandatorId = RequestPath.getMandator(req); final String uuid = RequestPath.getSession(req); // // Session handler (HTTP) and session control (OSGi) // //SessionControl ctrl = new HttpSessionControlImpl(context, req.getSession()); SessionControl ctrl = new SessionControlImpl(context); ctrl.setMandatorID(mandatorId); ctrl.setCertID(uuid); //RequestHandler rqHdl = new RequestHandler(context, ctrl); ctrl.loadTempSession(); ctrl.getAll(); ctrl.incRequestCounter(); ctrl.setAll(); ctrl.saveTempSession(); // // Session service // String cert = null; //The '0' session of the mandator Session mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), "0"); Integer baseIndex = ((Integer) mSession.getValue(Session.ENGINE_BASE_INDEX)).intValue(); //String sessionId = session.getId(); mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), ctrl.decodeCert().toString()); String[] elem = RequestPath.getPath(req); if (elem.length != 2) throw new MalformedURLException("The URL needs the form '" + req.getServletPath() + "/function-id/file-uuid' but was '" + req.getRequestURI() + "'"); BigInteger engineId = ctrl.decodeCert(); String functionId = elem.length >= 1 ? elem[0] : null; String fileUuid = elem.length >= 2 ? elem[1] : null; mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), ctrl.getCertID()); if (mSession == null) { List<String> list = ctrl.getShortTimePassword(); if (ctrl.getCertID() == null || (!list.contains(ctrl.getCertID()))) throw new UnavailableException("Needs a valid User-Session."); } DatabaseService dbService = DatabaseServiceImpl.getDatabase(context, cert, ctrl.getMandatorID()); if (dbService == null) { throw new UnavailableException( "Needs a valid database service for mandator " + ctrl.getMandatorID() + "."); } ResponseHandler rsHdl = new ResponseHandler(context, ctrl); Map<String, String> headers = new HashMap<String, String>(); try { // // Gets the engine base service // EngineBaseService engineBaseService = EngineBaseServiceImpl.getService(context, ctrl.getMandatorID(), String.valueOf(baseIndex)); if (engineBaseService == null) throw new IOException( "The mandator base service is not available (maybe down or a version conflict)."); // // Run the step // Mandator mandator = MandatorServiceImpl.getMandator(context, ctrl.getMandatorID()); if (mandator == null) throw new IOException( "The mandator service is not available (maybe down or a version conflict)."); Engine engine = engineBaseService.getEngine(engineId); if (!engine.isLogin()) throw new IllegalAccessException("There is no login to this session."); // // Initialize the work // engine.setLocalValue(httpSessionID, engineId.toString()); //ctrl.decodeCert().toString() IdRep processUUID = IdGen.getUUID(); engine.setLocalValue(httpProcessID, processUUID); IOContainer ioc = new IOContainer(); ioc.setProcessUUID(processUUID.toString()); ioc.setField(openFileByID, fileUuid); engine.setLocalValue(httpIOContainer, ioc); // // Call script // try { engine.call(functionId); } catch (Exception e) { e.printStackTrace(); } //Prints a file out //rsHdl.getSessionData(buffer, mSession); InputStream in = null; try { //DbDatabase dbs = dbService.getDatabase(); //DbFileStore dbf = dbs.getFileStore(); //DbFile file = dbf.getFileFromId( (String)engine.getLocalValue(openFileByRef) ); String[] fn = ioc.getFilenames(); if (fn.length == 0) throw new IllegalArgumentException("There is no file specified to open (empty array)."); DbFile file = (DbFile) ioc.getFile(fn[0]); in = file.getInputStream(); headers.put("Content-Type", file.getMimetype()); headers.put("Content-Length", String.valueOf(file.getLength())); rsHdl.avoidCaching(resp); rsHdl.sendFile(in, resp, headers); } finally { if (in != null) in.close(); ioc.cleanup(); engine.setLocalValue(httpSessionID, null); engine.setLocalValue(httpProcessID, null); engine.setLocalValue(httpIOContainer, null); } } catch (Exception e) { logger.error("Error running the step.", e); } } catch (Exception e) { ResponseHandler rsHdl = new ResponseHandler(context, null); rsHdl.sendError(logger, e, resp, null); } }