Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

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

Prototype

public Throwable() 

Source Link

Document

Constructs a new throwable with null as its detail message.

Usage

From source file:org.apache.ranger.biz.UserMgr.java

public XXPortalUserRole addUserRole(Long userId, String userRole) {
    List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole().findByUserId(userId);
    boolean publicRole = false;
    for (int i = 0; i < publicRoles.length; i++) {
        if (publicRoles[i].equalsIgnoreCase(userRole)) {
            publicRole = true;/*  w ww . java2s. c om*/
            break;
        }
    }
    if (!publicRole) {
        UserSessionBase sess = ContextUtil.getCurrentUserSession();
        if (sess == null) {
            return null;
        }
        // Admin
        if (!sess.isUserAdmin() && !sess.isKeyAdmin()) {
            logger.error("SECURITY WARNING: User trying to add non public role. userId=" + userId + ", role="
                    + userRole + ", session=" + sess.toString(), new Throwable());
            return null;
        }
    }

    for (XXPortalUserRole gjUserRole : roleList) {
        if (userRole.equalsIgnoreCase(gjUserRole.getUserRole())) {
            return gjUserRole;
        }
    }
    XXPortalUserRole userRoleObj = new XXPortalUserRole();
    userRoleObj.setUserRole(userRole.toUpperCase());
    userRoleObj.setUserId(userId);
    userRoleObj.setStatus(RangerConstants.STATUS_ENABLED);
    daoManager.getXXPortalUserRole().create(userRoleObj);

    // If role is not OTHER, then remove OTHER
    if (!RangerConstants.ROLE_OTHER.equalsIgnoreCase(userRole)) {
        deleteUserRole(userId, RangerConstants.ROLE_OTHER);
    }

    sessionMgr.resetUserSessionForProfiles(ContextUtil.getCurrentUserSession());
    return null;
}

From source file:com.wb.launcher3.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *//*from  w w w.  ja  v a2 s.  c  om*/
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(null);

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            //*/zhangwuba modify 
            if (!TydtechConfig.SHOW_SHORTCUT_NAME_IN_HOTSEAT_FLAG) {
                ((FolderIcon) child).setTextVisible(false);
            } else {
                ((FolderIcon) child).setTextVisible(true);
            }
            //*/
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY);
    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java

private void addLinkOfLayerizerFromFlow(String networkId, Flow flow) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");
    String linkId = null;/* ww  w .j a v  a  2 s .  c  om*/
    if (null != layerizedlinks) {
        linkId = layerizedlinks.get(flow.getFlowId());
        logger.debug("** get linkId={}", linkId);
    }

    NetworkInterface layerizerNetworkIf = networkInterfaces().get(getLayerizerNetworkId());

    if (null == linkId) {
        Link link = createLinkFromFlow(flow);
        link.setId(getUniqueLinkId(getLayerizerNetworkId()));
        if (null == link || !link.validate()) {
            logger.debug("** link create failure.");
            return;
        }

        Response ret = layerizerNetworkIf.postLink(link);
        logger.debug("** Response:" + ret.statusCode);
        logger.debug("** Response Body:" + ret.getBodyValue().toString());

        try {
            linkId = ret.getBody(Link.class).getId();
            putLowerFlows(linkId, flow.getFlowId());
            putLayerizedlinks(linkId, flow.getFlowId());
        } catch (Exception e) {
            logger.error("post link error.");
        }
    } else {
        logger.debug("** flow status:" + flow.getStatus());

        Link link = layerizerNetworkIf.getLink(linkId);

        Map<String, String> linkAttributes = link.getAttributes();
        linkAttributes.put(AttrElements.OPER_STATUS, STATUS_UP);
        linkAttributes.put(AttrElements.ESTABLISHMENT_STATUS, flow.getStatus());
        linkAttributes.put(AttrElements.LATENCY, flow.getAttribute(AttrElements.LATENCY));
        linkAttributes.put(AttrElements.MAX_BANDWIDTH, flow.getAttribute(AttrElements.BANDWIDTH));
        linkAttributes.put(AttrElements.UNRESERVED_BANDWIDTH, LINK_DEFAULT_UNRESERVED_BANDWIDTH);
        linkAttributes.put(TableManager.TRANSACTION_ID, flow.getAttribute(TableManager.TRANSACTION_ID));
        link.putAttributes(linkAttributes);

        Response ret = layerizerNetworkIf.putLink(link);

        logger.debug("** Response:" + ret.statusCode);
        logger.debug("** Response Body:" + ret.getBodyValue().toString());

        return;
    }
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " End");
}

From source file:com.aidy.launcher3.ui.workspace.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and
 * dimension of the child are defined by x, y, spanX and spanY.
 * /*from  www.  j  ava2 s  . c  o  m*/
 * @param child
 *            The child to add in one of the workspace's screens.
 * @param screenId
 *            The screen in which to add the child.
 * @param x
 *            The X position of the child in the screen's grid.
 * @param y
 *            The Y position of the child in the screen's grid.
 * @param spanX
 *            The number of cells spanned horizontally by the child.
 * @param spanY
 *            The number of cells spanned vertically by the child.
 * @param insert
 *            When true, the child is inserted at the beginning of the
 *            children list.
 * @param computeXYFromRank
 *            When true, we use the rank (stored in screenId) to compute the
 *            x and y position in which to place hotseat items. Otherwise we
 *            use the x and y position to compute the rank.
 */
public void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY,
        boolean insert, boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are
            // adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(null);

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this
    // screen
    int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY);
    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

From source file:com.yourkey.billing.util.InAppBilling.java

private String getErrorLocation(int stackFrame) {
    StackTraceElement element = new Throwable().getStackTrace()[stackFrame + 1];
    String className = element.getClassName();
    if (className.startsWith(packageName + "."))
        className = className.substring(packageName.length() + 1);
    return ("Error location: " + element.getFileName() + " (" + Integer.toString(element.getLineNumber())
            + ")\n" + className + "." + element.getMethodName());
}

From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java

private void updateLinkOfLayerizerFromFlow(String networkId, Flow flow) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");
    String linkId = null;/*from   w ww  . j av  a 2s  . c  o  m*/
    if (null != layerizedlinks) {
        linkId = layerizedlinks.get(flow.getFlowId());
        logger.debug("** get linkId={}", linkId);
    }

    NetworkInterface layerizerNetworkIf = networkInterfaces().get(getLayerizerNetworkId());

    if (null == linkId) {
        Link link = createLinkFromFlow(flow);
        if (null == link) {
            logger.debug("** link create failure.");
            return;
        }
        link.setId(getUniqueLinkId(getLayerizerNetworkId()));
        link.putAttribute(AttrElements.OPER_STATUS, STATUS_UP);

        if (!link.validate()) {
            logger.debug("** link create failure.");
            return;
        }
        Response ret = layerizerNetworkIf.postLink(link);

        logger.debug("** Response:" + ret.statusCode);
        logger.debug("** Response Body:" + ret.getBodyValue().toString());

        try {
            linkId = ret.getBody(Link.class).getId();
            putLowerFlows(linkId, flow.getFlowId());
            putLayerizedlinks(linkId, flow.getFlowId());
        } catch (Exception e) {
            logger.error("post link error.");
        }

    } else {
        Link link = layerizerNetworkIf.getLink(linkId);

        Map<String, String> linkAttributes = link.getAttributes();
        linkAttributes.put(AttrElements.OPER_STATUS, STATUS_UP);
        linkAttributes.put(AttrElements.ESTABLISHMENT_STATUS, flow.getStatus());
        linkAttributes.put(AttrElements.LATENCY, flow.getAttribute(AttrElements.LATENCY));
        linkAttributes.put(AttrElements.MAX_BANDWIDTH, flow.getAttribute(AttrElements.BANDWIDTH));
        linkAttributes.put(AttrElements.UNRESERVED_BANDWIDTH, LINK_DEFAULT_UNRESERVED_BANDWIDTH);
        linkAttributes.put(TableManager.TRANSACTION_ID, flow.getAttribute(TableManager.TRANSACTION_ID));
        link.putAttributes(linkAttributes);

        Response ret = layerizerNetworkIf.putLink(link);
        logger.debug("** Response:" + ret.statusCode);
        logger.debug("** Response Body:" + ret.getBodyValue().toString());
    }
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " End");
}

From source file:org.docx4j.XmlUtils.java

public static void transform(org.w3c.dom.Document doc, javax.xml.transform.Templates template,
        Map<String, Object> transformParameters, javax.xml.transform.Result result) throws Docx4JException {

    if (doc == null) {
        Throwable t = new Throwable();
        throw new Docx4JException("Null DOM Doc", t);
    }//from  ww w .j  a  v  a2 s  . co m

    javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(doc);

    transform(domSource, template, transformParameters, result);
}

From source file:org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper.java

/**
 * Close this ZooKeeper session./*  w  w w.jav  a  2s. co  m*/
 */
public void close() {
    try {
        recoverableZK.close();
        if (!INSTANCES.containsKey(instanceName)) {
            LOG.error("No ZooKeeper instance with key " + instanceName + " found:" + instanceName
                    + ", probably already closed.", new Throwable());
            closedUnknownZKWrapper = true;
        }
        INSTANCES.remove(instanceName);
        LOG.debug("<" + instanceName + ">" + "Closed connection with ZooKeeper; " + this.rootRegionZNode);
    } catch (InterruptedException e) {
        LOG.warn("<" + instanceName + ">" + "Failed to close connection with ZooKeeper");
    }
}

From source file:com.phonemetra.turbo.launcher.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *///from   w  w w . ja v  a 2 s .  c  o  m
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    //Reload settings
    reloadSettings();
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(null);

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(!mHideIconLabels);
        } else if (child instanceof BubbleTextView) {
            ((BubbleTextView) child).setTextVisibility(!mHideIconLabels);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {

    }

    if (!(child instanceof Folder)) {
        if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            child.setHapticFeedbackEnabled(false);
        }
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

From source file:com.auratech.launcher.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *//*from  www  .  j a  v  a2 s.com*/
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(null);

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}