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.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java

private void putLayerizedlinks(String layerLinkId, String lowFlowId) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");
    layerizedlinks.put(lowFlowId, layerLinkId);
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " End");
}

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

private BasicFlow linkToFlow(NetworkInterface networkInterface, Link link) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");

    String srcPortId = link.getSrcPort();
    String srcNodeId = link.getSrcNode();
    String dstPortId = link.getDstPort();
    String dstNodeId = link.getDstNode();

    FlowSet flowSet = networkInterface.getFlowSet();
    if (null == flowSet) {
        flowSet = new FlowSet();
    }// ww w . ja va 2  s . c  o m

    BasicFlow flow = (BasicFlow) flowSet.createFlow(FlowType.BASIC_FLOW, FLOW_PRIORITY);
    flow.setStatus(FlowStatus.ESTABLISHING.toString());
    flow.setOwner("Any");
    flow.setEnabled(true);
    flow.setPriority(FLOW_PRIORITY);

    String[] lowerMatch = changePortBoundaryUppreToLow(srcNodeId, srcPortId);
    BasicFlowMatch match = new BasicFlowMatch(lowerMatch[0], lowerMatch[1]);

    logger.debug("** match:{},{}", match.inNode, match.inPort);

    flow.addMatch(match);

    String[] upperEdgeAction = changePortBoundaryUppreToLow(dstNodeId, dstPortId);
    if (null != upperEdgeAction[0] && null != upperEdgeAction[1]) {
        FlowActionOutput actionOutput = new FlowActionOutput(upperEdgeAction[1]);
        flow.addEdgeAction(upperEdgeAction[0], actionOutput);
    }

    Map<String, String> flowAttributes = new HashMap<String, String>();

    flowAttributes.put(AttrElements.BANDWIDTH,
            StringUtils.defaultString(link.getAttribute(AttrElements.MAX_BANDWIDTH)));
    flowAttributes.put(AttrElements.REQ_BANDWIDTH,
            StringUtils.defaultString(link.getAttribute(AttrElements.REQ_BANDWIDTH)));
    flowAttributes.put(AttrElements.LATENCY,
            StringUtils.defaultString(link.getAttribute(AttrElements.LATENCY)));
    flowAttributes.put(AttrElements.REQ_LATENCY,
            StringUtils.defaultString(link.getAttribute(AttrElements.REQ_LATENCY)));
    flowAttributes.put(TableManager.TRANSACTION_ID,
            StringUtils.defaultString(link.getAttribute(TableManager.TRANSACTION_ID)));

    flow.putAttributes(flowAttributes);
    flow.setVersion("0");

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

From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java

/**
 * ?/*from   w w  w.ja  va2 s  . co  m*/
 * @param request
 * @param response
 * @return
 */
@RequestMapping("/addNewCarInfo")
public String addNewCarInfo(HttpServletRequest request, HttpServletResponse response) {
    Map<String, String> pageParam = super.getParametersFromPage(request);
    Map<String, Object> vo = null;

    long startTime = System.currentTimeMillis();

    String uId = null;
    try {
        //            Object obj = request.getSession().getAttribute("newVehicleModel");
        uId = super.getUserInfo(request).getUid();
        String vehicleModelKey = uId + VEHICLE_MODEL_KEY_PREFIX;
        Object obj = spyMemcachedClient.get(vehicleModelKey);
        if (obj != null) {
            vo = (HashMap<String, Object>) obj;
            UserModel userModel = (UserModel) request.getSession()
                    .getAttribute(Constant.ALIPAY_USER_SESSION_KEY);
            vo.put("uid", userModel.getUid());
            if (pageParam.get("viNumber") != null) {
                vo.put("viNumber", URLDecoder.decode(pageParam.get("viNumber"), "UTF-8").toUpperCase());
            }
            if (StringUtils.isNotEmpty(pageParam.get("viStartTime"))) {// 
                vo.put("viStartTime",
                        DateUtil.parserDateFromString(pageParam.get("viStartTime"), DateUtil.DATEFORMAT5));
            }
            if (StringUtils.isNotEmpty(pageParam.get("vlCityId"))) {// 
                vo.put("vlCityId", pageParam.get("vlCityId"));
            }
            if (StringUtils.isNotEmpty(pageParam.get("vlCityName"))) {// ??
                vo.put("vlCityName", URLDecoder.decode(pageParam.get("vlCityName"), "UTF-8"));
            }
            // 
            vo.put("viMileage", pageParam.get("viMileage"));

            // ?
            vo.put("viVin", pageParam.get("viVin").toUpperCase());

            // ??
            vo.put("engineNo", pageParam.get("engineNo").toUpperCase());

            //                request.getSession().setAttribute("newVehicleModel", vo);
            this.spyMemcachedClient.set(vehicleModelKey, Constant.MEMCACHED_SAVETIME_24, vo);
            // 1?sofa?
            Map<String, String> resMap = myCarManageService.addVehicle(vo);
            if (resMap == null) {// ???
                if (logger.isErrorEnabled()) {
                    logger.error("????sofa?null");
                }
                super.redirectErrorPage("BUSY-ERR", "???", null, null, response);
                return null;
            } else if (!Constant.SOFA_RETURN_CODE_SUCCESS.equals(resMap.get("returnCode"))) {
                String errorMsg = "?";
                if ("11006".equals(resMap.get("returnCode"))) {
                    errorMsg = "";
                }
                if (logger.isErrorEnabled()) {
                    logger.error(
                            "????sofa??{} |??{}",
                            resMap.get("returnCode"), resMap.get("returnDesc"));
                }
                logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null,
                        "????", startTime);
                super.redirectErrorPage("BUSY-ERR", errorMsg, null, null, response);
                return null;
            } else {
                String backUrl = "/car/myCarList";
                Object backObj = request.getSession().getAttribute("backUrl");
                if (backObj != null) {
                    backUrl = backObj.toString();
                }
                request.setAttribute("backUrl", backUrl);
                logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.SUCCESS, null,
                        "?????", startTime);
                return new StringBuilder("redirect:").append(backUrl).toString();
            }
        } else { // ?
            logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null,
                    "????", startTime);
            super.redirectErrorPage("BUSY-ERR", ",?", null, null, response);
            return null;
        }
    } catch (Exception e) {
        if (logger.isErrorEnabled()) {
            logger.error("????", e);
        }
        logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null,
                "????", startTime);
        super.redirectErrorPage("BUSY-ERR", "???", null, null, response);
        return null;
    }
}

From source file:dev.ukanth.ufirewall.Api.java

/**
 * Runs a script as root (multiple commands separated by "\n")
* @param ctx mandatory context/* w w w .  j ava 2s .  c  o m*/
 * @param script the script to be executed
 * @param res the script output response (stdout + stderr)
 * @return the script exit code
 * @throws IOException on any error executing the script, or writing it to disk
 */
public static int runScriptAsRoot(Context ctx, List<String> script, StringBuilder res) throws IOException {
    int returnCode = -1;

    if ((Looper.myLooper() != null) && (Looper.myLooper() == Looper.getMainLooper())) {
        Log.e(TAG, "runScriptAsRoot should not be called from the main thread\nCall Trace:\n");
        for (StackTraceElement e : new Throwable().getStackTrace()) {
            Log.e(TAG, e.toString());
        }
    }

    try {
        returnCode = new RunCommand().execute(script, res, ctx).get();
    } catch (RejectedExecutionException r) {
        Log.e(TAG, "runScript failed: " + r.getLocalizedMessage());
    } catch (InterruptedException e) {
        Log.e(TAG, "Caught InterruptedException");
    } catch (ExecutionException e) {
        Log.e(TAG, "runScript failed: " + e.getLocalizedMessage());
    } catch (Exception e) {
        Log.e(TAG, "runScript failed: " + e.getLocalizedMessage());
    }

    return returnCode;
}

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

private String[] changePortBoundaryUppreToLow(String nodeId, String portId) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");

    logger.debug("** nodeId:" + nodeId);
    logger.debug("** portId:" + portId);

    String[] ret = { "", "" };

    Set<String> keySet = boundaryset.getLinklayerizerBoundaryMap().keySet();
    Iterator<String> boundaryIterator = keySet.iterator();
    while (boundaryIterator.hasNext()) {
        String key = boundaryIterator.next();
        logger.debug("** key:" + key);
        LinklayerizerBoundary lb = boundaryset.getLinklayerizerBoundaryMap().get(key);
        logger.debug("** lb:" + lb.getUpper_nw_port());
        if (lb.getUpper_nw_node().equals(nodeId) && lb.getUpper_nw_port().equals(portId)) {
            ret[0] = lb.getLower_nw_node();
            ret[1] = lb.getLower_nw_port();
            logger.debug("** match ok");
            break;
        }//from w  ww  .  jav  a2s .  c o m
    }

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

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

private String[] changePortBoundaryLowToUpper(String nodeId, String portId) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");

    logger.debug("** nodeId:" + nodeId);
    logger.debug("** portId:" + portId);

    String[] ret = { "", "" };

    Set<String> keySet = boundaryset.getLinklayerizerBoundaryMap().keySet();
    Iterator<String> boundaryIterator = keySet.iterator();
    while (boundaryIterator.hasNext()) {
        String key = boundaryIterator.next();
        logger.debug("** key:" + key);
        LinklayerizerBoundary lb = boundaryset.getLinklayerizerBoundaryMap().get(key);
        logger.debug("** lb:" + lb.getUpper_nw_port());
        if (lb.getLower_nw_node().equals(nodeId) && lb.getLower_nw_port().equals(portId)) {
            ret[0] = lb.getUpper_nw_node();
            ret[1] = lb.getUpper_nw_port();
            break;
        }//from   w  w  w.  j  a v  a  2  s. c o m
    }

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

From source file:org.apache.usergrid.persistence.Schema.java

/** @return entity properties from columns as a map */
public static Map<String, Object> deserializeEntityProperties(Map<String, ByteBuffer> columns, boolean checkId,
        boolean checkRequired) {

    if (columns == null) {
        return null;
    }/* www.  j  a v a  2s .c o  m*/

    String entityType = string(columns.get(PROPERTY_TYPE));
    if (entityType == null) {
        logger.debug("deserializeEntityProperties(): No type for entity found, entity probably doesn't exist");
        return null;
    }
    if (checkId && !columns.containsKey(PROPERTY_UUID)) {
        logger.error("No id for entity ( {} ) found!", entityType);
        return null;
    }

    if (checkRequired) {
        Set<String> required_properties = Schema.getDefaultSchema().getRequiredProperties(entityType);
        if (required_properties != null) {
            for (String property_name : required_properties) {
                if (!columns.containsKey(property_name)) {
                    logger.error("Entity (" + entityType + ") missing required property: " + property_name,
                            new Throwable());
                    return null;
                }
            }
        }
    }

    Map<String, Object> properties_map = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (Entry<String, ByteBuffer> column : columns.entrySet()) {
        String propertyName = column.getKey();
        Object propertyValue = deserializeEntityProperty(entityType, propertyName, column.getValue());
        properties_map.put(propertyName, propertyValue);
    }
    return properties_map;
}

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

private boolean checkUpperEvent(String networkId) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");
    String type = conversionTable().getConnectionType(networkId);

    // check connection type
    if (!UPPER.equals(type)) {
        logger.debug("type not upper.");
        return false;
    }/*from  w w  w  . ja  v  a 2 s  . com*/

    // check layerizer has been registered
    if (!conversionTable().isConnectionType(LAYERIZER)) {
        logger.debug("layerizer networkInterface Not found.");
        return false;
    }
    return true;
}

From source file:org.apereo.portal.layout.dlm.DistributedLayoutManager.java

/**
 * Resets the layout of the specified user.
 *//* w  ww.j  a  v  a  2s.  c o m*/
private boolean resetLayout(IPerson person) {
    final String userName = person.getUserName();
    if (PersonFactory.GUEST_USERNAMES.contains(userName)) {
        throw new IllegalArgumentException("CANNOT RESET LAYOUT FOR A GUEST USER: " + person);
    }
    LOG.warn("Resetting user layout for: " + userName, new Throwable());

    boolean layoutWasReset = false;

    /*
     * is the person being reset a fragment owner? Can't use the
     * isFramentOwner variable in this class since we could be resetting 
     * another user's layout.
     */
    if (this.distributedLayoutStore.isFragmentOwner(person)) {
        // set template user override so reload of layout comes from
        // fragment template user
        person.setAttribute(org.apereo.portal.Constants.TEMPLATE_USER_NAME_ATT,
                FragmentDefinition.getDefaultLayoutOwnerId());
    }
    IUserIdentityStore userStore = UserIdentityStoreLocator.getUserIdentityStore();

    try {
        userStore.removePortalUID(person.getID());
        userStore.getPortalUID(person, true);

        // see if the current user was the one to reset their layout and if
        // so we need to refresh our local copy of their layout
        if (person == owner) {
            this.layoutCachingService.removeCachedLayout(person, profile);
            updateCacheKey();
            getUserLayoutDOM();
        }
        //if (isFragmentOwner)
        //{
        //    
        //    store.updateOwnerLayout(person);
        //}
        layoutWasReset = true;
    } catch (Exception e) {
        LOG.error("Unable to reset layout for " + person.getAttribute(IPerson.USERNAME) + ".", e);
    }
    return layoutWasReset;
}

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

private boolean checkLayerizerUpperEvent(String networkId, Link link) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");

    if (checkLayerizerEvent(networkId, link) || checkUpperEvent(networkId)) {
        logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " True End");
        return true;
    }//from  ww w.  j a v a2 s. co  m
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " False End");
    return false;
}