Example usage for java.math BigInteger ZERO

List of usage examples for java.math BigInteger ZERO

Introduction

In this page you can find the example usage for java.math BigInteger ZERO.

Prototype

BigInteger ZERO

To view the source code for java.math BigInteger ZERO.

Click Source Link

Document

The BigInteger constant zero.

Usage

From source file:edu.hku.sdb.rewrite.SdbSchemeRewriter.java

/**
 * Rewrite a normal join predicate./*from  www.j  a v a  2s . co  m*/
 *
 * @param normalBinPred
 * @param leftS
 * @param rightS
 * @param targetM
 * @param targetX
 * @throws RewriteException
 */
protected void rewriteNorBinJoinPred(NormalBinPredicate normalBinPred, SelectionItem leftS,
        SelectionItem rightS, BigInteger targetM, BigInteger targetX) throws RewriteException {
    LOG.debug("Rewriting join predicate for " + normalBinPred.toSql());
    if (!normalBinPred.involveEncrytedCol())
        return;

    if (normalBinPred.getOp() != BinaryPredicate.BinOperator.EQ) {
        UnSupportedException e = new UnSupportedException(
                "Can not support condition" + " " + normalBinPred.getOp() + " in join clause!");
        LOG.error("There is unsupported join condition!", e);
        throw e;
    }

    Expr leftExpr = normalBinPred.getLeftExpr();
    Expr rightExpr = normalBinPred.getRightExpr();

    if (!(leftExpr instanceof FieldLiteral && rightExpr instanceof FieldLiteral)) {
        UnSupportedException e = new UnSupportedException("Can not support " + "non-column join attributes!");
        LOG.error("There is unsupported join condition!", e);
        throw e;
    }

    FieldLiteral leftField = (FieldLiteral) leftExpr;
    FieldLiteral rightField = (FieldLiteral) rightExpr;

    if (!leftField.getType().equals(Type.INT) || !rightField.getType().equals(Type.INT)) {
        UnSupportedException e = new UnSupportedException("Can not support " + "non-integer join attributes!");
        LOG.error("There is unsupported join condition!", e);
        throw e;
    }

    // EE mode
    if (leftField.involveEncrytedCol() && rightField.involveEncrytedCol()) {
        SdbColumnKey leftSColKey = leftS.getExpr().getSdbColKey();

        // The auxiliary update values p, q for the left field
        BigInteger[] pqLeft = SDBEncrypt.keyUpdateClient(leftExpr.getSdbColKey().getM(), targetM,
                leftSColKey.getM(), leftExpr.getSdbColKey().getX(), targetX, leftSColKey.getX(), prime1,
                prime2);

        // The auxiliary update values p, q for the right field
        BigInteger[] pqRight = SDBEncrypt.keyUpdateClient(rightExpr.getSdbColKey().getM(), targetM,
                rightS.getExpr().getSdbColKey().getM(), rightExpr.getSdbColKey().getX(), targetX,
                rightS.getExpr().getSdbColKey().getX(), prime1, prime2);

        // The order must be:(field, auxiliaryS, p, q, n)
        Expr leftKeyUp = buildSdbKeyUpdateExpr(leftExpr, leftS.getExpr(), new BigIntLiteral(pqLeft[0]),
                new BigIntLiteral(pqLeft[1]), new BigIntLiteral(n), targetM, targetX);
        Expr rightKeyUp = buildSdbKeyUpdateExpr(rightExpr, rightS.getExpr(), new BigIntLiteral(pqRight[0]),
                new BigIntLiteral(pqRight[1]), new BigIntLiteral(n), targetM, targetX);

        // Replace the original predicate
        normalBinPred.setLeftExpr(leftKeyUp);
        normalBinPred.setRightExpr(rightKeyUp);
    } else {
        if (leftField.involveEncrytedCol()) {
            SdbColumnKey leftSColKey = leftS.getExpr().getSdbColKey();

            // The auxiliary update values p, q for the left field
            BigInteger[] pqLeft = SDBEncrypt.keyUpdateClient(leftExpr.getSdbColKey().getM(), targetM,
                    leftSColKey.getM(), leftExpr.getSdbColKey().getX(), targetX, leftSColKey.getX(), prime1,
                    prime2);

            // The auxiliary update values p, q for the right field
            BigInteger[] pqRight = SDBEncrypt.keyUpdateClient(BigInteger.ONE, targetM,
                    rightS.getExpr().getSdbColKey().getM(), BigInteger.ZERO, targetX,
                    rightS.getExpr().getSdbColKey().getX(), prime1, prime2);

            // The order must be:(field, auxiliaryS, p, q, n)
            Expr leftKeyUp = buildSdbKeyUpdateExpr(leftExpr, leftS.getExpr(), new BigIntLiteral(pqLeft[0]),
                    new BigIntLiteral(pqLeft[1]), new BigIntLiteral(n), targetM, targetX);
            Expr rightKeyUp = buildSdbKeyUpdateExpr(rightExpr, rightS.getExpr(), new BigIntLiteral(pqRight[0]),
                    new BigIntLiteral(pqRight[1]), new BigIntLiteral(n), targetM, targetX);

            // Replace the original predicate
            normalBinPred.setLeftExpr(leftKeyUp);
            normalBinPred.setRightExpr(rightKeyUp);
        } else {
            SdbColumnKey leftSColKey = leftS.getExpr().getSdbColKey();

            // The auxiliary update values p, q for the left field
            BigInteger[] pqLeft = SDBEncrypt.keyUpdateClient(BigInteger.ONE, targetM, leftSColKey.getM(),
                    BigInteger.ZERO, targetX, leftSColKey.getX(), prime1, prime2);

            // The auxiliary update values p, q for the right field
            BigInteger[] pqRight = SDBEncrypt.keyUpdateClient(rightExpr.getSdbColKey().getM(), targetM,
                    rightS.getExpr().getSdbColKey().getM(), rightExpr.getSdbColKey().getX(), targetX,
                    rightS.getExpr().getSdbColKey().getX(), prime1, prime2);

            // The order must be:(field, auxiliaryS, p, q, n)
            Expr leftKeyUp = buildSdbKeyUpdateExpr(leftExpr, leftS.getExpr(), new BigIntLiteral(pqLeft[0]),
                    new BigIntLiteral(pqLeft[1]), new BigIntLiteral(n), targetM, targetX);
            Expr rightKeyUp = buildSdbKeyUpdateExpr(rightExpr, rightS.getExpr(), new BigIntLiteral(pqRight[0]),
                    new BigIntLiteral(pqRight[1]), new BigIntLiteral(n), targetM, targetX);

            // Replace the original predicate
            normalBinPred.setLeftExpr(leftKeyUp);
            normalBinPred.setRightExpr(rightKeyUp);
        }
    }
}

From source file:de.schildbach.litecoinwallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    final String action = intent.getAction();

    if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
        notificationCount = 0;//  w ww .j ava  2s. c o  m
        notificationAccumulatedAmount = BigInteger.ZERO;
        notificationAddresses.clear();

        nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
    }

    if (BlockchainService.ACTION_HOLD_WIFI_LOCK.equals(action)) {
        log.debug("acquiring wifilock");
        wifiLock.acquire();
    } else {
        log.debug("releasing wifilock");
        wifiLock.release();
    }

    if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
        log.info("will remove blockchain on service shutdown");

        resetBlockchainOnShutdown = true;
        stopSelf();
    }

    if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
        final Sha256Hash hash = new Sha256Hash(
                intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
        final Transaction tx = application.getWallet().getTransaction(hash);

        if (peerGroup != null) {
            log.info("broadcasting transaction " + tx.getHashAsString());
            peerGroup.broadcastTransaction(tx);
        } else {
            log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
        }
    }

    return START_NOT_STICKY;
}

From source file:ja.keystore00.wallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (intent != null) {
        log.info("service start command: " + intent
                + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                        ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                        : ""));

        final String action = intent.getAction();

        if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
            notificationCount = 0;// www  .  j  a  v  a 2  s  . c o  m
            notificationAccumulatedAmount = BigInteger.ZERO;
            notificationAddresses.clear();

            nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
        } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
            log.info("will remove blockchain on service shutdown");

            resetBlockchainOnShutdown = true;
            stopSelf();
        } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
            final Sha256Hash hash = new Sha256Hash(
                    intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
            final Transaction tx = application.getWallet().getTransaction(hash);

            if (peerGroup != null) {
                log.info("broadcasting transaction " + tx.getHashAsString());
                peerGroup.broadcastTransaction(tx);
            } else {
                log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
            }
        }
    }
    return START_NOT_STICKY;
}

From source file:org.docx4j.convert.in.xhtml.XHTMLImporter.java

private void traverse(Box box, List<Object> contentContext, Box parent, TableProperties tableProperties)
        throws Docx4JException {

    log.debug(box.getClass().getName());
    if (box instanceof BlockBox) {
        BlockBox blockBox = ((BlockBox) box);

        Element e = box.getElement();

        // Don't add a new paragraph if this BlockBox is display: inline
        if (e == null) {
            // Shouldn't happen
            log.debug("<NULL>");
        } else {/*from  w  ww  .  ja  va 2s .co  m*/
            log.debug("BB" + "<" + e.getNodeName() + " " + box.getStyle().toStringMine());

            //Map cssMap = styleReference.getCascadedPropertiesMap(e);
            Map<String, CSSValue> cssMap = getCascadedProperties(box.getStyle());

            /* Sometimes, when it is display: inline, the following is not set:
               CSSValue cssValue = (CSSValue)cssMap.get("display");
               if (cssValue !=null) {
             log.debug(cssValue.getCssText() );
               }
            */
            // So do it this way ...
            if (box.getStyle().getDisplayMine().equals("inline")) {
                // Don't add a paragraph for this, unless ..
                if (currentP == null) {
                    currentP = Context.getWmlObjectFactory().createP();
                    contentContext.add(currentP);
                    paraStillEmpty = true;
                }

            } else if (box instanceof org.docx4j.org.xhtmlrenderer.newtable.TableSectionBox) {
                // nb, both TableBox and TableSectionBox 
                // have node name 'table' (or can have),
                // so this else clause is before the TableBox one,
                // to avoid a class cast exception

                // eg <tbody color: #000000; background-color: transparent; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: [0%, 0%]; background-size: [auto, auto]; border-collapse: collapse; -fs-border-spacing-horizontal: 0; -fs-border-spacing-vertical: 0; -fs-font-metric-src: none; -fs-keep-with-inline: auto; -fs-page-width: auto; -fs-page-height: auto; -fs-page-sequence: auto; -fs-pdf-font-embed: auto; -fs-pdf-font-encoding: Cp1252; -fs-page-orientation: auto; -fs-table-paginate: auto; -fs-text-decoration-extent: line; bottom: auto; caption-side: top; clear: none; ; content: normal; counter-increment: none; counter-reset: none; cursor: auto; ; display: table-row-group; empty-cells: show; float: none; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: normal; font-family: serif; -fs-table-cell-colspan: 1; -fs-table-cell-rowspan: 1; height: auto; left: auto; letter-spacing: normal; list-style-type: disc; list-style-position: outside; list-style-image: none; max-height: none; max-width: none; min-height: 0; min-width: 0; orphans: 2; ; ; ; overflow: visible; page: auto; page-break-after: auto; page-break-before: auto; page-break-inside: auto; position: static; ; right: auto; src: none; table-layout: auto; text-align: left; text-decoration: none; text-indent: 0; text-transform: none; top: auto; ; vertical-align: middle; visibility: visible; white-space: normal; word-wrap: normal; widows: 2; width: auto; word-spacing: normal; z-index: auto; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; 
                log.debug(".. processing <tbody");

                // Do nothing here for now .. the switch statement below traverses children

                // TODO: give effect to this CSS

            } else if (box instanceof org.docx4j.org.xhtmlrenderer.newtable.TableBox) {

                log.debug(".. processing table"); // what happened to <colgroup><col style="width: 2.47in;" /><col style="width: 2.47in;" /> 

                /*
                 * BEWARE: xhtmlrenderer seems to parse tables differently,
                 * depending on whether:
                 * 
                 * (i) the table is contained within a <div>
                 * 
                 * (ii) the table contains <caption>
                 * 
                 * See https://github.com/plutext/flyingsaucer/issues/1
                 * 
                 * Bare table with caption: BlockBox cannot be cast to TableSectionBox in xhtmlrenderer
                 * 
                 * div/table[count(caption)=1] ... table becomes TableBox, children are CONTENT_BLOCK
                 * 
                 * div/table[count(caption)=0] ... table becomes TableBox, children are CONTENT_BLOCK
                 * 
                 * 
                        
                 * 
                 */

                org.docx4j.org.xhtmlrenderer.newtable.TableBox cssTable = (org.docx4j.org.xhtmlrenderer.newtable.TableBox) box;

                tableProperties = new TableProperties();
                tableProperties.setTableBox(cssTable);

                // eg <table color: #000000; background-color: transparent; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: [0%, 0%]; background-size: [auto, auto]; 
                //           border-collapse: collapse; -fs-border-spacing-horizontal: 2px; -fs-border-spacing-vertical: 2px; -fs-font-metric-src: none; -fs-keep-with-inline: auto; -fs-page-width: auto; -fs-page-height: auto; -fs-page-sequence: auto; -fs-pdf-font-embed: auto; -fs-pdf-font-encoding: Cp1252; -fs-page-orientation: auto; -fs-table-paginate: auto; -fs-text-decoration-extent: line; bottom: auto; caption-side: top; clear: none; ; content: normal; counter-increment: none; counter-reset: none; cursor: auto; ; display: table; empty-cells: show; float: none; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: normal; font-family: serif; -fs-table-cell-colspan: 1; -fs-table-cell-rowspan: 1; height: auto; left: auto; letter-spacing: normal; list-style-type: disc; list-style-position: outside; list-style-image: none; max-height: none; max-width: none; min-height: 0; min-width: 0; orphans: 2; ; ; ; overflow: visible; page: auto; page-break-after: auto; page-break-before: auto; page-break-inside: auto; position: relative; ; right: auto; src: none; 
                //           table-layout: fixed; text-align: left; text-decoration: none; text-indent: 0; text-transform: none; top: auto; ; vertical-align: baseline; visibility: visible; white-space: normal; word-wrap: normal; widows: 2; width: auto; word-spacing: normal; z-index: auto; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0in; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;

                contentContext = nestedTableHierarchyFix(contentContext, parent);

                Tbl tbl = Context.getWmlObjectFactory().createTbl();
                contentContext.add(tbl);
                paraStillEmpty = true;
                contentContext = tbl.getContent();

                TblPr tblPr = Context.getWmlObjectFactory().createTblPr();
                tbl.setTblPr(tblPr);

                TblStyle tblStyle = Context.getWmlObjectFactory().createCTTblPrBaseTblStyle();
                tblStyle.setVal("TableGrid");
                tblPr.setTblStyle(tblStyle);

                // borders.  rudimentary support
                // for now, look just at border-top-style.
                // If it is not 'none', for example 'solid', display a border.
                // cssTable.getBorder requires a CssContext; so just
                FSDerivedValue borderTopStyle = box.getStyle().valueByName(CSSName.BORDER_TOP_STYLE);
                if (borderTopStyle != null // what to default to if its null?
                        && borderTopStyle.asString().toLowerCase().contains("none")) {
                    log.debug("setting borders to none");
                    try {
                        TblBorders borders = (TblBorders) XmlUtils.unmarshalString(WORDML_TABLE_BORDERS,
                                Context.jc, TblBorders.class);
                        tblPr.setTblBorders(borders);
                    } catch (JAXBException e1) {
                    }
                }

                // Table indent.  
                // cssTable.getLeftMBP() which is setLeftMBP((int) margin.left() + (int) border.left() + (int) padding.left());
                // cssTable.getTx(); which is (int) margin.left() + (int) border.left() + (int) padding.left();
                // But want just margin.left
                if (cssTable.getMargin() != null && cssTable.getMargin().left() > 0) {
                    log.debug("Calculating TblInd from margin.left: " + cssTable.getMargin().left());
                    TblWidth tblIW = Context.getWmlObjectFactory().createTblWidth();
                    tblIW.setW(BigInteger.valueOf(Math.round(cssTable.getMargin().left())));
                    tblIW.setType(TblWidth.TYPE_DXA);
                    tblPr.setTblInd(tblIW);
                }

                // <w:tblW w:w="0" w:type="auto"/>
                // for both fixed width and auto fit tables.
                // You'd only set it to something else
                // eg <w:tblW w:w="5670" w:type="dxa"/>
                // for what in Word corresponds to 
                // "Preferred width".  TODO: decide what CSS
                // requires that.
                TblWidth tblW = Context.getWmlObjectFactory().createTblWidth();
                tblW.setW(BigInteger.ZERO);
                tblW.setType(TblWidth.TYPE_AUTO);
                tblPr.setTblW(tblW);

                if (cssTable.getStyle().isIdent(CSSName.TABLE_LAYOUT, IdentValue.AUTO)
                        || cssTable.getStyle().isAutoWidth()) {
                    // Conditions under which FS creates AutoTableLayout

                    tableProperties.setFixedWidth(false);

                    // This is the default, so no need to set 
                    // STTblLayoutType.AUTOFIT

                } else {
                    // FS creates FixedTableLayout
                    tableProperties.setFixedWidth(true);

                    // <w:tblLayout w:type="fixed"/>
                    CTTblLayoutType tblLayout = Context.getWmlObjectFactory().createCTTblLayoutType();
                    tblLayout.setType(STTblLayoutType.FIXED);
                    tblPr.setTblLayout(tblLayout);
                }

                // Word can generally open a table without tblGrid:
                // <w:tblGrid>
                //  <w:gridCol w:w="4621"/>
                //  <w:gridCol w:w="4621"/>
                // </w:tblGrid>
                // but for an AutoFit table (most common), it 
                // is the w:gridCol val which prob specifies the actual width
                TblGrid tblGrid = Context.getWmlObjectFactory().createTblGrid();
                tbl.setTblGrid(tblGrid);

                int[] colPos = tableProperties.getColumnPos();

                for (int i = 1; i <= cssTable.numEffCols(); i++) {

                    TblGridCol tblGridCol = Context.getWmlObjectFactory().createTblGridCol();
                    tblGrid.getGridCol().add(tblGridCol);

                    log.debug("colpos=" + colPos[i]);
                    tblGridCol.setW(BigInteger.valueOf(colPos[i] - colPos[i - 1]));

                }

            } else if (e.getNodeName().equals("table")) {
                // but not instanceof org.docx4j.org.xhtmlrenderer.newtable.TableBox
                // .. this does happen.  See test/resources/block-level-lots.xhtml

                // TODO: look at whether we can style the table in this case

                log.warn("Encountered non-TableBox table: " + box.getClass().getName());

                contentContext = nestedTableHierarchyFix(contentContext, parent);

                Tbl tbl = Context.getWmlObjectFactory().createTbl();
                contentContext.add(tbl);
                paraStillEmpty = true;
                contentContext = tbl.getContent();

            } else if (box instanceof org.docx4j.org.xhtmlrenderer.newtable.TableRowBox) {

                // eg <tr color: #000000; background-color: transparent; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: [0%, 0%]; background-size: [auto, auto]; border-collapse: collapse; -fs-border-spacing-horizontal: 0; -fs-border-spacing-vertical: 0; -fs-font-metric-src: none; -fs-keep-with-inline: auto; -fs-page-width: auto; -fs-page-height: auto; -fs-page-sequence: auto; -fs-pdf-font-embed: auto; -fs-pdf-font-encoding: Cp1252; -fs-page-orientation: auto; -fs-table-paginate: auto; -fs-text-decoration-extent: line; bottom: auto; caption-side: top; clear: none; ; content: normal; counter-increment: none; counter-reset: none; cursor: auto; ; display: table-row; empty-cells: show; float: none; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: normal; font-family: serif; -fs-table-cell-colspan: 1; -fs-table-cell-rowspan: 1; height: auto; left: auto; letter-spacing: normal; list-style-type: disc; list-style-position: outside; list-style-image: none; max-height: none; max-width: none; min-height: 0; min-width: 0; orphans: 2; ; ; ; overflow: visible; page: auto; page-break-after: auto; page-break-before: auto; page-break-inside: auto; position: static; ; right: auto; src: none; table-layout: auto; text-align: left; text-decoration: none; text-indent: 0; text-transform: none; top: auto; ; vertical-align: top; visibility: visible; white-space: normal; word-wrap: normal; widows: 2; width: auto; word-spacing: normal; z-index: auto; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;

                // TODO support vertical-align

                log.debug(".. processing <tr");

                Tr tr = Context.getWmlObjectFactory().createTr();
                contentContext.add(tr);
                paraStillEmpty = true;
                contentContext = tr.getContent();

            } else if (box instanceof org.docx4j.org.xhtmlrenderer.newtable.TableCellBox) {

                log.debug(".. processing <td");
                // eg <td color: #000000; background-color: transparent; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: [0%, 0%]; background-size: [auto, auto]; border-collapse: collapse; -fs-border-spacing-horizontal: 0; -fs-border-spacing-vertical: 0; -fs-font-metric-src: none; -fs-keep-with-inline: auto; -fs-page-width: auto; -fs-page-height: auto; -fs-page-sequence: auto; -fs-pdf-font-embed: auto; -fs-pdf-font-encoding: Cp1252; -fs-page-orientation: auto; -fs-table-paginate: auto; -fs-text-decoration-extent: line; bottom: auto; caption-side: top; clear: none; ; content: normal; counter-increment: none; counter-reset: none; cursor: auto; ; display: table-row; empty-cells: show; float: none; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: normal; font-family: serif; -fs-table-cell-colspan: 1; -fs-table-cell-rowspan: 1; height: auto; left: auto; letter-spacing: normal; list-style-type: disc; list-style-position: outside; list-style-image: none; max-height: none; max-width: none; min-height: 0; min-width: 0; orphans: 2; ; ; ; overflow: visible; page: auto; page-break-after: auto; page-break-before: auto; page-break-inside: auto; position: static; ; right: auto; src: none; table-layout: auto; text-align: left; text-decoration: none; text-indent: 0; text-transform: none; top: auto; ; vertical-align: top; visibility: visible; white-space: normal; word-wrap: normal; widows: 2; width: auto; word-spacing: normal; z-index: auto; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;

                List<Object> trContext = contentContext;
                org.docx4j.org.xhtmlrenderer.newtable.TableCellBox tcb = (org.docx4j.org.xhtmlrenderer.newtable.TableCellBox) box;
                // tcb.getVerticalAlign()

                // rowspan support: vertically merged cells are
                // represented as a top cell containing the actual content with a vMerge tag with "restart" attribute 
                // and a series of dummy cells having a vMerge tag with no (or "continue") attribute.                  

                // if cell to the left in source is part of a rowspan, 
                // insert dummy cell first                     
                int effCol;
                TableSectionBox section = tcb.getSection();
                effCol = tcb.getTable().colToEffCol(tcb.getCol());
                if (effCol != 0) {
                    TableCellBox prevCell = section.cellAt(tcb.getRow(), tcb.getCol() - 1);
                    log.debug("Got prevCell for " + tcb.getRow() + ", " + tcb.getCol());
                    log.debug("it is  " + prevCell.getRow() + ", " + prevCell.getCol());
                    if (prevCell.getRow() < tcb.getRow() && prevCell.getStyle() != null
                            && prevCell.getStyle().getRowSpan() > 1) {
                        // eg tcb is r2,c1 & prevCell is r1,c0
                        Tc dummy = Context.getWmlObjectFactory().createTc();
                        contentContext.add(dummy);

                        TcPr tcPr = Context.getWmlObjectFactory().createTcPr();
                        dummy.setTcPr(tcPr);

                        VMerge vm = Context.getWmlObjectFactory().createTcPrInnerVMerge();
                        //vm.setVal("continue");
                        tcPr.setVMerge(vm);

                        this.setCellWidthAuto(tcPr);

                        // Must have an empty w:p
                        dummy.getContent().add(new P());
                    }
                }

                // The cell proper
                Tc tc = Context.getWmlObjectFactory().createTc();
                contentContext.add(tc);
                contentContext = tc.getContent();

                // if the td contains bare text (eg <td>apple</td>)
                // we need a p for it
                currentP = Context.getWmlObjectFactory().createP();
                contentContext.add(currentP);
                paraStillEmpty = true;

                // Do we need a vMerge tag with "restart" attribute?
                // get cell below (only 1 section supported at present)
                TcPr tcPr = Context.getWmlObjectFactory().createTcPr();
                tc.setTcPr(tcPr);
                if (tcb.getStyle().getRowSpan() > 1) {

                    VMerge vm = Context.getWmlObjectFactory().createTcPrInnerVMerge();
                    vm.setVal("restart");
                    tcPr.setVMerge(vm);
                }
                // eg <w:tcW w:w="2268" w:type="dxa"/>
                try {
                    TblWidth tblW = Context.getWmlObjectFactory().createTblWidth();
                    tblW.setW(BigInteger.valueOf(tableProperties.getColumnWidth(effCol + 1)));
                    tblW.setType(TblWidth.TYPE_DXA);
                    tcPr.setTcW(tblW);
                } catch (java.lang.ArrayIndexOutOfBoundsException aioob) {
                    // happens with http://en.wikipedia.org/wiki/Office_Open_XML
                    log.error("Problem with getColumnWidth for col" + (effCol + 1));
                }
                /*                  The below works, but the above formulation is simpler
                 * 
                 *                int r = tcb.getRow() + tcb.getStyle().getRowSpan() - 1;
                                    if (r < tcb.getSection().numRows() - 1) {
                // The cell is not in the last row, so use the next row in the
                // section.
                TableCellBox belowCell = section.cellAt( r + 1, effCol);
                                       log.debug("Got belowCell for " + tcb.getRow() + ", " + tcb.getCol() );
                                       log.debug("it is  " + belowCell.getRow() + ", " + belowCell.getCol() );
                if (belowCell.getRow() > tcb.getRow() + 1 ) {
                 TcPr tcPr = Context.getWmlObjectFactory().createTcPr();
                tc.setTcPr(tcPr);
                        
                VMerge vm = Context.getWmlObjectFactory().createTcPrInnerVMerge();
                vm.setVal("restart");
                tcPr.setVMerge(vm);                           
                }
                                    } 
                 */

                // if this is the last real cell in the source,
                // is there a rowspan above and to the right?
                effCol = tcb.getTable().colToEffCol(tcb.getCol() + tcb.getStyle().getColSpan());
                int numEffCols = tcb.getTable().numEffCols();
                if (effCol >= numEffCols) {
                    // we we're already in rightmost col
                } else {
                    TableCellBox nextCell = tcb.getSection().cellAt(tcb.getRow(), effCol);
                    if (nextCell == null) {
                        //throw new Docx4JException("XHTML table import: Null nextCell for row " + tcb.getRow() + ", col " + tcb.getCol()); // Check your table is OK
                        log.error("XHTML table import: Null nextCell for row " + tcb.getRow() + ", col "
                                + tcb.getCol()); // Check your table is OK
                        // eg http://en.wikipedia.org/w/index.php?title=Microsoft_Word&printable=yes
                    } else {
                        log.debug("Got nextCell for " + tcb.getRow() + ", " + tcb.getCol());
                        log.debug("it is  " + nextCell.getRow() + ", " + nextCell.getCol());
                        if (nextCell.getRow() < tcb.getRow()
                                // && nextCell.getStyle().getRowSpan()>1
                                && nextCell.getTable().colToEffCol(
                                        nextCell.getCol() + nextCell.getStyle().getColSpan()) == numEffCols // rightmost
                        ) {
                            log.debug("it has rowspan  " + nextCell.getStyle().getRowSpan());
                            // eg tcb is r2,c1 & nextCell is r1,c2
                            Tc dummy = Context.getWmlObjectFactory().createTc();
                            trContext.add(dummy);

                            TcPr tcPr2 = Context.getWmlObjectFactory().createTcPr();
                            dummy.setTcPr(tcPr2);

                            VMerge vm = Context.getWmlObjectFactory().createTcPrInnerVMerge();
                            //vm.setVal("continue");
                            tcPr2.setVMerge(vm);

                            this.setCellWidthAuto(tcPr2);

                            // Must have an empty w:p
                            dummy.getContent().add(new P());
                        }
                    }
                }

                // colspan support: horizontally merged cells are represented by one cell
                // with a gridSpan attribute; 
                int colspan = tcb.getStyle().getColSpan();
                if (colspan > 1) {

                    if (tc.getTcPr() != null) {
                        log.warn("Trying to add GridSpan, when we've already added VMerge"); // this code doesn't support both at once
                    }

                    TcPr tcPr2 = Context.getWmlObjectFactory().createTcPr();
                    tc.setTcPr(tcPr2);

                    GridSpan gs = Context.getWmlObjectFactory().createTcPrInnerGridSpan();
                    gs.setVal(BigInteger.valueOf(colspan));
                    tcPr2.setGridSpan(gs);

                    this.setCellWidthAuto(tcPr2);
                }

            } else {

                // Avoid creating paragraphs for html, body
                if (contentContext.size() > 0 && paraStillEmpty) {
                    contentContext.remove(contentContext.size() - 1);
                }

                currentP = Context.getWmlObjectFactory().createP();
                contentContext.add(currentP);
                paraStillEmpty = true;

                // Paragraph level styling
                currentP.setPPr(addParagraphProperties(cssMap));

                if (e.getNodeName().equals("li")) {
                    addNumbering(e, cssMap);
                } else if (e.getNodeName().equals("img")) {
                    // TODO, should we be using ReplacedElementFactory approach instead?                     
                    addImage(e);
                }

            }
        }

        // the recursive bit:

        Object lastChild = null;

        log.debug("Processing children of " + box.getElement().getNodeName());
        switch (blockBox.getChildrenContentType()) {
        case BlockBox.CONTENT_BLOCK:
            log.debug(".. which are BlockBox.CONTENT_BLOCK");
            for (Object o : ((BlockBox) box).getChildren()) {

                lastChild = o;

                traverse((Box) o, contentContext, box, tableProperties);
                log.debug(".. processed child " + o.getClass().getName());
            }
            break;
        case BlockBox.CONTENT_INLINE:

            log.debug(".. which are BlockBox.CONTENT_INLINE");

            if (((BlockBox) box).getInlineContent() != null) {

                for (Object o : ((BlockBox) box).getInlineContent()) {
                    //                            log.debug("        " + o.getClass().getName() ); 
                    if (o instanceof InlineBox) {
                        //                                    && ((InlineBox)o).getElement()!=null // skip these (pseudo-elements?)
                        //                                    && ((InlineBox)o).isStartsHere()) {

                        processInlineBox((InlineBox) o, contentContext);

                    } else if (o instanceof BlockBox) {
                        traverse((Box) o, contentContext, box, tableProperties); // commenting out gets rid of unwanted extra parent elements
                    } else {
                        log.debug("What to do with " + box.getClass().getName());
                    }
                    log.debug(".. processed child " + o.getClass().getName());
                }
            }
            break;
        }

        log.debug("Done processing children of " + box.getClass().getName());
        // contentContext gets its old value back each time recursion finishes,
        // ensuring elements are added at the appropriate level (eg inside tr) 

        // An empty tc shouldn't make the table disappear!
        // TODO - make more elegant
        if (e.getNodeName().equals("table")) {
            paraStillEmpty = false;
        }

        //           if ( (lastChild instanceof Box)
        //                 && ((Box)lastChild).getElement().getNodeName().equals("table") ) {
        //              System.out.println("## " + e.getNodeName() );
        //           }       

        // nested tables must end with a <p/> or Word 2010 can't open the docx!
        // ie:
        // <w:tc>
        //   <w:tbl>..</w:tbl>
        //   <w:p/>                <---------- 
        // </w:tc>
        // This fixes the dodgy table/table case
        if (box instanceof TableBox || box.getElement().getNodeName().equals("table")) {

            if ((lastChild instanceof Box) && ((Box) lastChild).getElement().getNodeName().equals("table")) {
                log.debug("Adding <w:p/> after nested table");
                P extraP = Context.getWmlObjectFactory().createP();

                Tr tr = (Tr) contentContext.get(contentContext.size() - 1);
                ((Tc) tr.getContent().get(tr.getContent().size() - 1)).getContent().add(extraP);
                //contentContext.add(extraP);                  
                paraStillEmpty = false; // ??                 
            }
        }

        if (e.getNodeName().equals("td")) { // untested

            if ((lastChild instanceof Box) && ((Box) lastChild).getElement().getNodeName().equals("table")) {
                log.debug("Adding <w:p/> after nested table");
                P extraP = Context.getWmlObjectFactory().createP();

                contentContext.add(extraP);
                paraStillEmpty = false; // ??                 
            }
        }

    } else if (box instanceof AnonymousBlockBox) {
        log.debug("AnonymousBlockBox");
    }

}

From source file:piuk.blockchain.android.MyRemoteWallet.java

private void sendCoinsToFriend(final String sendType, final String emailOrNumber, final BigInteger amount,
        final FeePolicy feePolicy, final BigInteger fee, final SendProgress progress) throws Exception {

    new Thread() {
        @Override//from w ww.j  a  v a2s  .  c om
        public void run() {
            progress.onStart();
            final List<ECKey> tempKeys = new ArrayList<ECKey>();

            try {
                final String[] from = getActiveAddresses();
                final ECKey key;
                Pair<ECKey, String> keyAndMiniKey = null;
                /*
                if (sendType == "sms") {
                   keyAndMiniKey = generateNewMiniPrivateKey();
                   key = keyAndMiniKey.first;                     
                } else {
                   key = generateECKey();
                }
                */
                keyAndMiniKey = generateNewMiniPrivateKey();
                key = keyAndMiniKey.first;

                //Construct a new transaction
                progress.onProgress("Getting Unspent Outputs");

                List<MyTransactionOutPoint> allUnspent = getUnspentOutputPoints(from);

                Pair<Transaction, Long> pair = null;

                progress.onProgress("Constructing Transaction");

                final DumpedPrivateKey dumpedPrivateKey = key.getPrivateKeyEncoded(getParams());
                String privateKey = Base58.encode(dumpedPrivateKey.bytes);

                final String toAddress = key.toAddress(getParams()).toString();
                /*
                Log.d("sendCoinsToFriend", "sendCoinsToFriend: privateKey: " + privateKey);
                Log.d("sendCoinsToFriend", "sendCoinsToFriend: toAddress: " + toAddress);
                */

                try {
                    //Try without asking for watch only addresses
                    List<MyTransactionOutPoint> unspent = filter(allUnspent, tempKeys, false, progress);
                    HashMap<String, BigInteger> receivingAddresses = new HashMap<String, BigInteger>();
                    receivingAddresses.put(toAddress, amount);
                    pair = makeTransaction(false, unspent, receivingAddresses, fee, null);

                    //Transaction cancelled
                    if (pair == null)
                        return;
                } catch (InsufficientFundsException e) {

                    //Try with asking for watch only
                    List<MyTransactionOutPoint> unspent = filter(allUnspent, tempKeys, true, progress);
                    HashMap<String, BigInteger> receivingAddresses = new HashMap<String, BigInteger>();
                    receivingAddresses.put(toAddress, amount);
                    pair = makeTransaction(false, unspent, receivingAddresses, fee, null);

                    //Transaction cancelled
                    if (pair == null)
                        return;
                }

                if (allUnspent != null) {
                    Transaction tx = pair.first;

                    progress.onProgress("Signing Inputs");

                    Wallet wallet = new Wallet(MainNetParams.get());
                    for (TransactionInput input : tx.getInputs()) {
                        byte[] scriptBytes = input.getOutpoint().getConnectedPubKeyScript();
                        String address = new BitcoinScript(scriptBytes).getAddress().toString();
                        final ECKey walletKey;
                        try {
                            walletKey = getECKey(address);
                        } catch (Exception e) {
                            // skip add Watch Only Bitcoin Address key because already accounted for  later with tempKeys
                            continue;
                        }
                        ECKey keyCompressed;
                        ECKey keyUnCompressed;
                        BigInteger priv = new BigInteger(walletKey.getPrivKeyBytes());
                        if (priv.compareTo(BigInteger.ZERO) >= 0) {
                            keyCompressed = new ECKey(priv, null, true);
                            keyUnCompressed = new ECKey(priv, null, false);
                        } else {
                            byte[] appendZeroByte = ArrayUtils.addAll(new byte[1], walletKey.getPrivKeyBytes());
                            BigInteger priv2 = new BigInteger(appendZeroByte);
                            keyCompressed = new ECKey(priv2, null, true);
                            keyUnCompressed = new ECKey(priv2, null, false);
                        }

                        if (keyCompressed != null) {
                            wallet.addKey(keyCompressed);
                        }

                        if (keyUnCompressed != null) {
                            wallet.addKey(keyUnCompressed);
                        }
                    }

                    wallet.addKeys(tempKeys);

                    //Now sign the inputs
                    tx.signInputs(SigHash.ALL, wallet);

                    progress.onProgress("Broadcasting Transaction");

                    final String txHash = tx.getHashAsString();

                    /*
                    Log.d("sendCoinsToFriend", "sendCoinsToFriend: txHash: " + txHash);                  
                    Log.d("sendCoinsToFriend", "sendCoinsToFriend: emailOrNumber: " + emailOrNumber);
                    */

                    Map<Object, Object> params = new HashMap<Object, Object>();
                    params.put("type", sendType);
                    //                  Log.d("sendCoinsToFriend", "type:" + sendType);
                    String privParameter = (sendType == "sms") ? keyAndMiniKey.second : privateKey;
                    params.put("priv", privParameter);
                    params.put("hash", txHash);
                    params.put("to", emailOrNumber);
                    //                  Log.d("sendCoinsToFriend", "to:" + emailOrNumber);
                    params.put("guid", getGUID());
                    params.put("sharedKey", getSharedKey());

                    try {
                        String response = WalletUtils.postURLWithParams(WebROOT + "send-via", params);
                        if (response != null && response.length() > 0) {
                            progress.onProgress("Send Transaction");
                            //                        Log.d("sendCoinsToFriend", "sendCoinsToFriend: send-via response: " + response);
                            String response2 = pushTx(tx);
                            if (response2 != null && response2.length() > 0) {
                                //                           Log.d("sendCoinsToFriend", "sendCoinsToFriend: pushTx response: " + response2);
                                progress.onSend(tx, response2);

                                String label = sendType == "email" ? emailOrNumber + " Sent Via Email"
                                        : emailOrNumber + " Sent Via SMS";
                                addKey(key, toAddress, label);
                                setTag(toAddress, 2);
                            }
                        }
                    } catch (Exception e) {
                        progress.onError(e.getMessage());
                        e.printStackTrace();
                    }
                }

            } catch (Exception e) {
                progress.onError(e.getMessage());
                e.printStackTrace();
            }

        }
    }.start();

}

From source file:com.cannabiscoin.wallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    log.info("service start command: " + intent
            + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                    ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                    : ""));

    final String action = intent.getAction();

    if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
        notificationCount = 0;//from   w w  w.j  a  v  a  2 s. com
        notificationAccumulatedAmount = BigInteger.ZERO;
        notificationAddresses.clear();

        nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
    } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
        log.info("will remove blockchain on service shutdown");

        resetBlockchainOnShutdown = true;
        //WalletApplication.scheduleStartBlockchainService(this);  //disconnect feature
        stopSelf();
    } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
        final Sha256Hash hash = new Sha256Hash(
                intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
        final Transaction tx = application.getWallet().getTransaction(hash);

        if (peerGroup != null) {
            log.info("broadcasting transaction " + tx.getHashAsString());
            peerGroup.broadcastTransaction(tx);
        } else {
            log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
        }
    } else if (BlockchainService.ACTION_STOP_SERVICE.equals(action)) {
        log.info("stopping self");
        // deliberate stop command, so don't schedule restart
        stopSelf();
    }

    return START_NOT_STICKY;
}

From source file:com.blu3f1re.reddwallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    log.info("service start command: " + intent
            + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                    ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                    : ""));

    final String action = intent.getAction();

    if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
        notificationCount = 0;/*from   w  ww. j  ava2 s.  c  o  m*/
        notificationAccumulatedAmount = BigInteger.ZERO;
        notificationAddresses.clear();

        nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
    } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
        log.info("will remove blockchain on service shutdown");

        resetBlockchainOnShutdown = true;
        stopSelf();
    } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
        final Sha256Hash hash = new Sha256Hash(
                intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
        final Transaction tx = application.getWallet().getTransaction(hash);

        if (peerGroup != null) {
            log.info("broadcasting transaction " + tx.getHashAsString());
            peerGroup.broadcastTransaction(tx);
        } else {
            log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
        }
    }

    return START_NOT_STICKY;
}

From source file:org.mule.module.extension.internal.capability.xml.schema.SchemaBuilder.java

private void generateNestedProcessorElement(ExplicitGroup all, Parameter parameter, String maxOccurs) {
    LocalComplexType collectionComplexType = new LocalComplexType();
    GroupRef group = generateNestedProcessorGroup(parameter, maxOccurs);
    collectionComplexType.setGroup(group);
    collectionComplexType.setAnnotation(createDocAnnotation(parameter.getDescription()));

    TopLevelElement collectionElement = new TopLevelElement();
    collectionElement.setName(hyphenize(parameter.getName()));
    collectionElement.setMinOccurs(parameter.isRequired() ? BigInteger.ONE : BigInteger.ZERO);
    collectionElement.setComplexType(collectionComplexType);
    collectionElement.setAnnotation(createDocAnnotation(EMPTY));
    all.getParticle().add(objectFactory.createElement(collectionElement));
}

From source file:com.kncwallet.wallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    String action = null;//w  ww . j a  v  a 2s.c o m

    if (intent == null) {
        log.info("Blockchain service started with null intent");
    } else {
        log.info("service start command: " + intent
                + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                        ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                        : ""));

        action = intent.getAction();
    }

    if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
        notificationCount = 0;
        notificationAccumulatedAmount = BigInteger.ZERO;
        notificationAddresses.clear();

        nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
    } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
        log.info("will remove blockchain on service shutdown");

        resetBlockchainOnShutdown = true;
        stopSelf();
    } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
        final Sha256Hash hash = new Sha256Hash(
                intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
        final Transaction tx = application.getWallet().getTransaction(hash);

        if (peerGroup != null) {
            log.info("broadcasting transaction " + tx.getHashAsString());
            peerGroup.broadcastTransaction(tx);
        } else {
            log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
        }
    }

    return START_NOT_STICKY;
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException {
    try {/* w  w  w.  ja  va 2  s .  c  o  m*/
        File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
        if (portrait != null && portrait.exists()) {
            Mtom mtomWs = getMtomWebService();

            CompleteAvatarWrapper avatar = new CompleteAvatarWrapper();

            avatar.setType(BigInteger.ZERO);
            avatar.setUserid(BigInteger.valueOf(userId));
            avatar.setFilename(portrait.getName());

            DataHandler portraitHandler = new DataHandler(new FileDataSource(portrait));
            avatar.setFile(portraitHandler);

            mtomWs.storeAvatar(avatar);
            return true;
        }
        return false;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        default:
            logAxisError("Cannot store the portrait of " + userId, f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot store the portrait of " + userId, e);
        return false;
    }
}