Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.mbv.web.rest.controller.VpGrnController.java

/**
 * @??excel//from   ww w  . j  a  v  a  2  s  .c  o m
 * @2015916
 * @param
 * @version
 */
@RequestMapping(value = "/importUpdateGrn", method = RequestMethod.POST)
@ResponseBody
public void importUpdateBill(
        @RequestParam(value = "update_vpGrn_importedFile", required = false) MultipartFile file,
        HttpServletRequest request, HttpServletResponse response) {
    JSONObject json = new JSONObject();
    try {
        // ?
        if (file.isEmpty()) {
            throw new MbvException("??");
        }
        // ??
        if (file.getSize() > 20971520) {
            throw new Exception("?20M?");
        }
        json = importFile(file);
    } catch (MbvException me) {
        me.printStackTrace();
        json.put("success", false);
        json.put("msg", me.getMessage());
    } catch (RuntimeException re) {
        re.printStackTrace();
        json.put("success", false);
        json.put("msg", re.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        json.put("success", false);
        json.put("msg", e.getMessage());
    }
    // ???
    outPrintJson(response, json.toString());
}

From source file:com.takondi.tartt.ARActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (areAnyRequiredPermissionsMissing()) {
        Intent intent = new Intent(this, PermissionActivity.class);
        startActivity(intent);/*from  w  ww. ja v a  2 s .c om*/
        finish();
        return;
    }

    setContentView(R.layout.activity_ar);

    mGuiHelper = new GuiHelper(this);
    mChannelManager = new ChannelManager(this);
    mArchitectView = (ArchitectView) findViewById(R.id.architectView);

    mGuiHelper.mSwitchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switchChannelRequested();
        }
    });
    mGuiHelper.mRetryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doInitialLoad();
        }
    });
    mGuiHelper.mCancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mChannelManager.cancel();
            mGuiHelper.changeGuiState(GUI_STATE.SCAN_QR);
            mQrPlugin.activate();
        }
    });
    final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();
    config.setLicenseKey(Const.WIKITUDE_KEY);
    config.setFeatures(ArchitectStartupConfiguration.Features.ImageTracking);
    try {
        mArchitectView.onCreate(config);
    } catch (RuntimeException e) {
        e.printStackTrace();
        mArchitectView = null;
    }
}

From source file:com.mbv.web.rest.controller.VpGrnController.java

/**
 * ??//from   w ww  . j  av  a  2 s .c  om
 */
@RequestMapping(value = "/getDefaultValue", method = RequestMethod.POST)
@ResponseBody
public void getDefaultValue(HttpServletRequest request, HttpServletResponse response) throws MbvException {
    // session??
    String orgCode = request.getSession().getAttribute(MbvConstant.UNIT_CODE).toString();
    if (orgCode == null || "".equals(orgCode)) {
        throw new MbvException("Session???");
    }
    try {
        String docCode = vpGrnService.getVpGrnMaxDocCode(MbvConstant.SEQ_NAME_VPGRN);
        if (docCode == null || "".equals(docCode)) {
            throw new MbvException("????");
        }
        String warehCode = request.getSession().getAttribute(MbvConstant.WAREH_CODE).toString();
        if (warehCode == null || "".equals(warehCode)) {
            throw new MbvException("Session???");
        }
        VpGrnEntity entity = new VpGrnEntity();
        entity.setDocCode(docCode);
        entity.setUnitCode(orgCode);
        entity.setWarehCode(warehCode);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("data", entity);
        // ??
        returnSuccess(response, map);
    } catch (MbvException me) {
        me.printStackTrace();
        throw new MbvException(me.getMessage());
    } catch (RuntimeException re) {
        re.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }
}

From source file:org.opencds.dss.evaluate.EvaluationImpl.java

@Override
public EvaluateResponse evaluate(Evaluate parameters) throws InvalidDriDataFormatExceptionFault,
        UnrecognizedLanguageExceptionFault, RequiredDataNotProvidedExceptionFault,
        UnsupportedLanguageExceptionFault, UnrecognizedScopedEntityExceptionFault, EvaluationExceptionFault,
        InvalidTimeZoneOffsetExceptionFault, DSSRuntimeExceptionFault {
    TimingData timingData = new TimingData();
    Date evalTime = new Date();
    log.debug("II: " + parameters.getInteractionId().getInteractionId().toString()
            + "EvaluationImpl.evaluate started asOf "
            + DateUtility.getInstance().getDateAsString(evalTime, "yyyyMMdd HHmmss").toString());
    if (!SimpleKnowledgeRepository.isKnowledgeRepositoryInitialized()) {
        SimpleKnowledgeRepository.setFullPathToKRData(OpencdsConfigurator.getInstance().getKrFullPath());
    }// w  ww  .j a v  a2  s .  c o  m

    DSSRequestDataItem dssRequestDataItem = new DSSRequestDataItem();
    dssRequestDataItem.setInteractionId(parameters.getInteractionId().getInteractionId().toString());

    EvaluateResponse evaluateResponse = new EvaluateResponse();
    evaluateResponse.setEvaluationResponse(new EvaluationResponse());

    List<KMEvaluationRequest> listKMERequest = OpenCDSMain.decodeInput(parameters.getEvaluationRequest(),
            //XMLDateUtility.xmlGregorian2Date(rightNowTime), 
            evalTime, dssRequestDataItem, timingData);

    for (KMEvaluationRequest oneKMEvaluationRequest : listKMERequest) {
        DSSRequestKMItem oneRequest = new DSSRequestKMItem();
        oneRequest.setDssRequestDataItem(dssRequestDataItem);
        oneRequest.setRequestedKmId(DSSUtility.makeEIString(oneKMEvaluationRequest.getKmId()));
        oneRequest.setKmTimingData(new TimingDataKM());
        initLogTimingsKM(oneRequest.getKmTimingData());

        Evaluater evaluater = EvaluationFactory.createEvaluater(oneRequest);
        String structuredDroolsResult = evaluater.getOneResponse(oneRequest);

        FinalKMEvaluationResponse fkmResponse = new FinalKMEvaluationResponse();
        SemanticPayload semanticPayload = new SemanticPayload();
        ItemIdentifier itemId = new ItemIdentifier();
        KMEvaluationResultData kmerData = new KMEvaluationResultData();
        List<byte[]> base64EncodedPayload = new ArrayList<byte[]>();

        try {
            log.debug("KMId: " + oneRequest.getRequestedKmId().toString()
                    + " EvaluationImpl.evaluate starting one KM");
            log.trace("" + structuredDroolsResult);
            base64EncodedPayload = semanticPayload.getBase64EncodedPayload();
            base64EncodedPayload.add(structuredDroolsResult.getBytes());

            itemId.setItemId(oneRequest.getDssRequestDataItem().getInputItemName() + ".EvaluationResult");
            itemId.setContainingEntityId(
                    DSSUtility.makeEI(oneRequest.getDssRequestDataItem().getInputContainingEntityId()));

            String kmId = oneRequest.getRequestedKmId();
            String ssIdString = SimpleKnowledgeRepository.getRequiredSSIdForKMId(kmId);
            EntityIdentifier ssId = DSSUtility.makeEI(ssIdString);
            semanticPayload.setInformationModelSSId(ssId);

            kmerData.setData(semanticPayload);
            kmerData.setEvaluationResultId(itemId);

            fkmResponse.setKmId(DSSUtility.makeEI(oneRequest.getRequestedKmId()));
            fkmResponse.getKmEvaluationResultData().add(kmerData);

            oneRequest.getKmTimingData().setFinishInferenceEngineAdapterTime(new AtomicLong(System.nanoTime()));
            log.debug("KMId: " + oneRequest.getRequestedKmId().toString()
                    + " EvaluationImpl.evaluate completed one KM");

        } catch (RuntimeException e) {
            e.printStackTrace();
            throw new DSSRuntimeExceptionFault(
                    "RuntimeException in EvaluationImpl.evaluate: " + structuredDroolsResult + e.getMessage());
        }
        evaluateResponse.getEvaluationResponse().getFinalKMEvaluationResponse().add(fkmResponse);

        logTimingsKM(oneRequest);
        oneRequest = null;
        structuredDroolsResult = null;
        evaluater = null;
        fkmResponse = null;
        semanticPayload = null;
        itemId = null;
        kmerData = null;
        base64EncodedPayload = null;
    }

    timingData.setFinishInferenceEngineLoopTime(new AtomicLong(System.nanoTime()));
    timingData.setFinishMessageRequestTime(new AtomicLong(System.nanoTime()));
    log.info("II: " + parameters.getInteractionId().getInteractionId().toString() + " " + logTimings(timingData)
            + " EvaluationImpl.evaluate completed");

    timingData = null;
    dssRequestDataItem = null;
    listKMERequest.clear();
    listKMERequest = null;

    return evaluateResponse;
}

From source file:com.mbv.web.rest.controller.VpGrnController.java

/**
 * @????/*from www  .  j a  v  a  2 s . co  m*/
 * @2015915
 * @param
 * @version
 * @throws Exception
 */
@RequestMapping(value = "/updateVpGrn", method = RequestMethod.POST)
@ResponseBody
public void updateVpGrn(@RequestBody VpGrnVo vo, HttpServletResponse response) throws Exception {
    // vo
    if (vo == null || vo.getEntity() == null) {
        throw new MbvException("???");
    }
    VpGrnEntity entity = vo.getEntity();
    try {
        // ??
        String errMessage = vpGrnService.validate(entity);
        if (errMessage != null && !"".equals(errMessage)) {
            throw new MbvException(errMessage);
        }
        List<VpGrnDtlEntity> details = vo.getDetails();
        // ????
        errMessage = vpGrnService.validateDetail(entity, details);
        if (errMessage != null && !"".equals(errMessage)) {
            throw new MbvException(errMessage);
        }
        boolean updateResult = vpGrnService.updateVpGrn(entity, details);
        log.info("updateVpGrn updateResult:" + updateResult);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("result", updateResult);
        // ??
        returnSuccess(response, map);
    } catch (MbvException me) {
        me.printStackTrace();
        throw new MbvException(me.getMessage());
    } catch (RuntimeException re) {
        re.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }
}

From source file:org.opencds.dss.evaluate.EvaluationImpl.java

@Override
public EvaluateAtSpecifiedTimeResponse evaluateAtSpecifiedTime(EvaluateAtSpecifiedTime parameters)
        throws InvalidDriDataFormatExceptionFault, UnrecognizedLanguageExceptionFault,
        RequiredDataNotProvidedExceptionFault, UnsupportedLanguageExceptionFault,
        UnrecognizedScopedEntityExceptionFault, EvaluationExceptionFault, InvalidTimeZoneOffsetExceptionFault,
        DSSRuntimeExceptionFault {/*from ww  w . j  a  v a2 s .c o m*/
    TimingData timingData = new TimingData();
    Date evalTime = XMLDateUtility.xmlGregorian2Date(parameters.getSpecifiedTime());
    log.debug("II: " + parameters.getInteractionId().getInteractionId().toString()
            + " EvaluationImpl.evaluateAtSpecifiedTime started asOf "
            + DateUtility.getInstance().getDateAsString(evalTime, "yyyyMMdd HHmmss").toString());
    if (!SimpleKnowledgeRepository.isKnowledgeRepositoryInitialized()) {
        SimpleKnowledgeRepository.setFullPathToKRData(OpencdsConfigurator.getInstance().getKrFullPath());
    }

    DSSRequestDataItem dssRequestDataItem = new DSSRequestDataItem();
    dssRequestDataItem.setInteractionId(parameters.getInteractionId().getInteractionId().toString());

    EvaluateAtSpecifiedTimeResponse evalAtSpecTimeResponse = new EvaluateAtSpecifiedTimeResponse();
    evalAtSpecTimeResponse.setEvaluationResponse(new EvaluationResponse());

    List<KMEvaluationRequest> listKMERequest = OpenCDSMain.decodeInput(parameters.getEvaluationRequest(),
            //XMLDateUtility.xmlGregorian2Date(parameters.getSpecifiedTime()), 
            evalTime, dssRequestDataItem, timingData);

    for (KMEvaluationRequest oneKMEvaluationRequest : listKMERequest) {
        DSSRequestKMItem oneRequest = new DSSRequestKMItem();
        oneRequest.setDssRequestDataItem(dssRequestDataItem);
        oneRequest.setRequestedKmId(DSSUtility.makeEIString(oneKMEvaluationRequest.getKmId()));
        oneRequest.setKmTimingData(new TimingDataKM());
        initLogTimingsKM(oneRequest.getKmTimingData());

        Evaluater evaluater = EvaluationFactory.createEvaluater(oneRequest);
        String structuredDroolsResult = evaluater.getOneResponse(oneRequest);

        FinalKMEvaluationResponse fkmResponse = new FinalKMEvaluationResponse();
        SemanticPayload semanticPayload = new SemanticPayload();
        ItemIdentifier itemId = new ItemIdentifier();
        KMEvaluationResultData kmerData = new KMEvaluationResultData();
        List<byte[]> base64EncodedPayload = new ArrayList<byte[]>();

        try {
            log.debug("KMId: " + oneRequest.getRequestedKmId().toString()
                    + " EvaluationImpl.evaluateAtSpecifiedTime starting one KM");
            log.trace("" + structuredDroolsResult);
            base64EncodedPayload = semanticPayload.getBase64EncodedPayload();
            base64EncodedPayload.add(structuredDroolsResult.getBytes());

            itemId.setItemId(oneRequest.getDssRequestDataItem().getInputItemName() + ".EvaluationResult");
            itemId.setContainingEntityId(
                    DSSUtility.makeEI(oneRequest.getDssRequestDataItem().getInputContainingEntityId()));

            String kmId = oneRequest.getRequestedKmId();
            String ssIdString = SimpleKnowledgeRepository.getRequiredSSIdForKMId(kmId);
            EntityIdentifier ssId = DSSUtility.makeEI(ssIdString);
            semanticPayload.setInformationModelSSId(ssId);

            kmerData.setData(semanticPayload);
            kmerData.setEvaluationResultId(itemId);

            fkmResponse.setKmId(DSSUtility.makeEI(oneRequest.getRequestedKmId()));
            fkmResponse.getKmEvaluationResultData().add(kmerData);

            oneRequest.getKmTimingData().setFinishInferenceEngineAdapterTime(new AtomicLong(System.nanoTime()));
            log.debug("KMId: " + oneRequest.getRequestedKmId().toString()
                    + " EvaluationImpl.evaluateAtSpecifiedTime completed one KM");

        } catch (RuntimeException e) {
            e.printStackTrace();
            throw new DSSRuntimeExceptionFault("RuntimeException in EvaluationImpl.evaluateAtSpecifiedTime: "
                    + structuredDroolsResult + e.getMessage());
        }

        evalAtSpecTimeResponse.getEvaluationResponse().getFinalKMEvaluationResponse().add(fkmResponse);
        evaluater = null;

        logTimingsKM(oneRequest);
        oneRequest = null;
        structuredDroolsResult = null;
        evaluater = null;
        fkmResponse = null;
        semanticPayload = null;
        itemId = null;
        kmerData = null;
        base64EncodedPayload = null;
    }

    timingData.setFinishInferenceEngineLoopTime(new AtomicLong(System.nanoTime()));
    timingData.setFinishMessageRequestTime(new AtomicLong(System.nanoTime()));
    log.info("II: " + parameters.getInteractionId().getInteractionId().toString() + " " + logTimings(timingData)
            + " EvaluationImpl.evaluateAtSpecifiedTime completed");

    timingData = null;
    dssRequestDataItem = null;
    listKMERequest.clear();
    listKMERequest = null;

    return evalAtSpecTimeResponse;
}

From source file:com.mbv.web.rest.controller.VpGrnController.java

/**
 * @????/*from   w  ww . j  a v a2 s .  c  om*/
 * @author gel
 * @2015827
 * @param
 * @version
 * @throws Exception 
 */
@RequestMapping(value = "/saveVpGrn", method = RequestMethod.POST)
@ResponseBody
public void addVpGrn(@RequestBody VpGrnVo vo, HttpServletResponse response) throws Exception {
    // vo
    if (vo == null) {
        throw new MbvException("???");
    }

    // ??
    VpGrnEntity vpGrnEntity = vo.getEntity();
    if (vpGrnEntity == null) {
        throw new MbvException("???");
    }
    try {
        // ??
        String errMessage = vpGrnService.validate(vpGrnEntity);
        if (errMessage != null && !"".equals(errMessage)) {
            throw new MbvException(errMessage);
        }
        List<VpGrnDtlEntity> details = vo.getDetails();
        // ????
        errMessage = vpGrnService.validateDetail(vpGrnEntity, details);
        if (errMessage != null && !"".equals(errMessage)) {
            throw new MbvException(errMessage);
        }

        // service?
        boolean isSuccess;
        isSuccess = vpGrnService.addVpGrn(vpGrnEntity, details);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("result", isSuccess);
        // ??
        returnSuccess(response, map);
    } catch (MbvException me) {
        me.printStackTrace();
        throw new MbvException(me.getMessage());
    } catch (RuntimeException re) {
        re.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }
}

From source file:ru.iris.events.EventsService.java

public EventsService() {
    Status status = new Status("Events");

    if (status.checkExist()) {
        status.running();//from   ww w  .  ja  va 2s . c o m
    } else {
        status.addIntoDB("Events", "Service that listen for events and exec scripts as needed");
    }

    try {

        events = Ebean.find(Event.class).findList();

        // take pause to save/remove new entity
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        // load all scripts, compile and put into map
        compiledScriptMap = loadAndCompile(events);

        // Pass jsonmessaging instance to js engine
        Bindings bindings = new SimpleBindings();
        bindings.put("jsonMessaging", jsonMessaging);
        bindings.put("LOGGER", scriptLogger);

        // subscribe to events from db
        for (Event event : events) {
            jsonMessaging.subscribe(event.getSubject());
            LOGGER.debug("Subscribe to subject: " + event.getSubject());
        }

        // command launch
        jsonMessaging.subscribe("event.command");

        // scripts
        jsonMessaging.subscribe("event.script.get");
        jsonMessaging.subscribe("event.script.save");
        jsonMessaging.subscribe("event.script.delete");
        jsonMessaging.subscribe("event.script.list");
        jsonMessaging.subscribe("event.reload");

        jsonMessaging.setNotification(new JsonNotification() {

            @Override
            public void onNotification(JsonEnvelope envelope) {

                LOGGER.debug("Got envelope with subject: " + envelope.getSubject());

                try {

                    // Get script content
                    if (envelope.getObject() instanceof EventGetScriptAdvertisement) {
                        LOGGER.debug("Return JS script to: " + envelope.getReceiverInstance());
                        EventGetScriptAdvertisement advertisement = envelope.getObject();
                        File jsFile;

                        if (advertisement.isCommand())
                            jsFile = new File("./scripts/command/" + advertisement.getName());
                        else
                            jsFile = new File("./scripts/" + advertisement.getName());

                        jsonMessaging.response(envelope,
                                new EventResponseGetScriptAdvertisement(FileUtils.readFileToString(jsFile)));

                    }
                    // Save new/existing script
                    else if (envelope.getObject() instanceof EventResponseSaveScriptAdvertisement) {

                        EventResponseSaveScriptAdvertisement advertisement = envelope.getObject();
                        LOGGER.debug("Request to save changes: " + advertisement.getName());
                        File jsFile;

                        if (advertisement.isCommand())
                            jsFile = new File("./scripts/command/" + advertisement.getName());
                        else
                            jsFile = new File("./scripts/" + advertisement.getName());

                        FileUtils.writeStringToFile(jsFile, advertisement.getBody());
                        LOGGER.info("Restart event service (reason: script change)");
                        reloadService();
                    }
                    // Remove script
                    else if (envelope.getObject() instanceof EventRemoveScriptAdvertisement) {

                        EventRemoveScriptAdvertisement advertisement = envelope.getObject();
                        LOGGER.debug("Request to remove script: " + advertisement.getName());
                        File jsFile;

                        if (advertisement.isCommand())
                            jsFile = new File("./scripts/command/" + advertisement.getName());
                        else
                            jsFile = new File("./scripts/" + advertisement.getName());

                        FileUtils.forceDelete(jsFile);
                        LOGGER.info("Restart event service (reason: script removed)");
                        reloadService();
                    }
                    // List available scripts
                    else if (envelope.getObject() instanceof EventListScriptsAdvertisement) {

                        EventListScriptsAdvertisement advertisement = envelope.getObject();
                        File jsFile;

                        if (advertisement.isCommand())
                            jsFile = new File("./scripts/command/");
                        else
                            jsFile = new File("./scripts/");

                        EventResponseListScriptsAdvertisement response = new EventResponseListScriptsAdvertisement();
                        response.setScripts(
                                (List<File>) FileUtils.listFiles(jsFile, new String[] { "js" }, false));

                        jsonMessaging.response(envelope, response);
                    }
                    // Check command and launch script
                    else if (envelope.getObject() instanceof CommandAdvertisement) {

                        CommandAdvertisement advertisement = envelope.getObject();
                        bindings.put("advertisement", envelope.getObject());

                        if (compiledCommandScriptMap.get(advertisement.getScript()) == null) {

                            LOGGER.debug("Compile command script: " + advertisement.getScript());

                            File jsFile = new File("./scripts/command/" + advertisement.getScript());
                            CompiledScript compile = engine.compile(FileUtils.readFileToString(jsFile));
                            compiledCommandScriptMap.put(advertisement.getScript(), compile);

                            LOGGER.debug("Launch compiled command script: " + advertisement.getScript());
                            compile.eval(bindings);
                        } else {
                            LOGGER.info("Launch compiled command script: " + advertisement.getScript());
                            compiledCommandScriptMap.get(advertisement.getScript()).eval(bindings);
                        }
                    } else if (envelope.getObject() instanceof EventChangesAdvertisement) {
                        reloadService();
                    } else {
                        for (Event event : events) {
                            if (envelope.getSubject().equals(event.getSubject())
                                    || wildCardMatch(event.getSubject(), envelope.getSubject())) {

                                LOGGER.debug("Run compiled script: " + event.getScript());

                                try {
                                    bindings.put("advertisement", envelope.getObject());
                                    CompiledScript script = compiledScriptMap.get(event.getScript());

                                    if (script != null)
                                        script.eval(bindings);
                                    else
                                        LOGGER.error("Error! Script " + event.getScript() + " is NULL!");

                                } catch (ScriptException e) {
                                    LOGGER.error("Error in script scripts/command/" + event.getScript() + ": "
                                            + e.toString());
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (ScriptException | IOException e) {
                    LOGGER.error("Error in script: " + e.toString());
                    e.printStackTrace();
                }
            }
        });

        jsonMessaging.start();
    } catch (final RuntimeException t) {
        LOGGER.error("Error in Events!");
        status.crashed();
        t.printStackTrace();
    }
}

From source file:com.mbv.web.rest.controller.VpGdnController.java

/**
 * @???id?//from   w  ww . j  av a 2  s  . c om
 * @2015915
 * @param
 * @version
 */
@RequestMapping(value = "/findVpGdnById", method = RequestMethod.POST)
@ResponseBody
public void findVpGdn(@RequestBody VpGdnVo vo, HttpServletResponse response) throws MbvException {
    // vo
    if (vo == null) {
        throw new MbvException("??");
    }
    try {
        VpGdnEntity entity = vpGdnService.getVpGdnByEntity(vo.getEntity());
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("data", entity);
        // ??
        returnSuccess(response, map);
    } catch (MbvException me) {
        me.printStackTrace();
        throw new MbvException(me.getMessage());
    } catch (RuntimeException re) {
        re.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }
}

From source file:nl.toolforge.karma.console.KarmaConsole.java

/**
 *
 * @param args  The working context (0), whether to update (1) and the command
 *              plus his options (3 ...).
 *///from www  . ja  v  a  2s  .  c o  m
public void runConsole(String[] args) {

    Runtime.getRuntime().addShutdownHook(new Thread() {

        public void run() {

            if (immediate) {

                String text = FRONTEND_MESSAGES.getString("message.THANK_YOU");
                int length = text.length();

                writeln("\n");

                writeln(FRONTEND_MESSAGES.getString("message.EXIT"));

                StringBuffer g = new StringBuffer();
                g.append("\n\n").append(StringUtils.repeat("*", length));
                g.append("\n").append(text).append("\n");
                g.append(StringUtils.repeat("*", length)).append("\n");

                writeln(g.toString());
            }
        }
    });

    // If the '-w <working-context> option is used, use it.
    //
    WorkingContext workingContext;
    if (args[0] == null || args[0].equals("")) {
        workingContext = new WorkingContext(
                Preferences.userRoot().get(WorkingContext.WORKING_CONTEXT_PREFERENCE, WorkingContext.DEFAULT));
    } else {
        workingContext = new WorkingContext(args[0]);
    }

    writeln("\n" + "      _________________________________\n" + "      Welcome to Karma (R1.0 RC1) !!!!!\n"
            + "\n" + "      K     A     R        M        A\n" + "      .     .     .        .        .\n"
            + "      Karma Ain't Remotely Maven or Ant\n" + "      _________________________________\n");

    String karmaHome = System.getProperty("karma.home");
    if (karmaHome == null) {
        writeln("[ console ] Property 'karma.home' not set; logging will be written to "
                + System.getProperty("user.home") + File.separator + "logs.");
    } else {
        writeln("[ console ] Logging will be written to " + System.getProperty("karma.home") + File.separator
                + "logs.");
    }

    writeln("[ console ] Checking working context configuration for `" + workingContext.getName() + "`.");

    WorkingContextConfiguration configuration = null;

    try {
        configuration = new WorkingContextConfiguration(workingContext);
        try {
            configuration.load();
        } catch (WorkingContextException e) {
        }

        workingContext.configure(configuration);

        // Check the validity state of the configuration.
        //

        ErrorCode error = configuration.check();
        ErrorCode error2 = null;
        ErrorCode error3 = null;

        if (error != null) {
            writeln("[ console ] ** Error in working context configuration : " + error.getErrorMessage());
        }
        if (configuration.getManifestStore() == null) {
            writeln("[ console ] ** Error in working context configuration : Missing configuration for manifest store.");
        } else {
            error2 = configuration.getManifestStore().checkConfiguration();
            if (error2 != null) {
                writeln("[ console ] ** Error in working context configuration : " + error2.getErrorMessage());
            }
        }
        if (configuration.getLocationStore() == null) {
            writeln("[ console ] ** Error in working context configuration : Missing configuration for location store.");
        } else {
            error3 = configuration.getLocationStore().checkConfiguration();
            if (error3 != null) {
                writeln("[ console ] ** Error in working context configuration : " + error3.getErrorMessage());
            }
        }

        while (error != null || configuration.getManifestStore() == null || error2 != null
                || configuration.getLocationStore() == null || error3 != null) {

            // todo hier eerst de foutmelding tonen.

            // todo offline-mode ?

            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

            String start = "";
            try {
                while (!start.matches("n|y")) {
                    write("[ console ] Working context not initialized properly, start configurator ? [Y|N] (Y) :");
                    start = (reader.readLine().trim()).toLowerCase();
                    start = ("".equals(start) ? "y" : start);
                }
            } catch (IOException e) {
                start = "n";
            }

            if ("n".equals(start)) {
                writeln("[ console ] ** Configuration incomplete. Cannot start Karma.");
                writeln("[ console ] Check configuration manually.");

                System.exit(1);

            } else {
                Configurator configurator = new Configurator(workingContext, configuration);
                configurator.checkConfiguration();

                // Run checks once more.
                //
                error = configuration.check();
                if (configuration.getManifestStore() != null) {
                    error2 = configuration.getManifestStore().checkConfiguration();
                }
                if (configuration.getLocationStore() != null) {
                    error3 = configuration.getLocationStore().checkConfiguration();
                }
            }
        }

    } catch (RuntimeException r) {
        writeln("\n");
        if (logger.isDebugEnabled()) {
            r.printStackTrace();
        }
        System.exit(1);
    }

    writeln("[ console ] Configuration complete. Loading working context `" + workingContext.getName()
            + "` ...");

    // Right now, we have a valid configuration and continue to load the working context.
    //
    workingContext.configure(configuration);

    writeln("[ console ] Configuration can be manually updated in `"
            + workingContext.getWorkingContextConfigurationBaseDir() + "`");

    writeln("\n[ console ] Starting up console ...\n");

    //
    //
    commandContext = new CommandContext(workingContext);
    try {
        //      long start = System.currentTimeMillis();
        commandContext.init(new ConsoleCommandResponseHandler(this), new Boolean(args[1]).booleanValue());
        //      System.out.println("TOTAL STARTUP-TIME: " + (System.currentTimeMillis() - start));
    } catch (CommandException e) {
        logger.warn(e.getMessage());
    }

    try {

        // Open a reader, which is the actual command line ...
        //
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String line = null;
        while (true) {

            prompt();

            if (reader != null || reader.readLine() != null) {
                line = reader.readLine().trim();
            }

            if ((line == null) || ("".equals(line.trim()))) {
                prompt();
                continue;
            }

            if ("[A".equals(line)) {
                line = lastLine;
                writeln(line);
            } else {
                lastLine = line;
            }

            try {
                commandContext.execute(line);
            } catch (CommandException e) {
                // The command context has already sent all required messages.
                //
            }
        }
    } catch (Throwable e) {
        writeln("\n");
        logger.fatal("Exception caught by KarmaConsole catch-all. ", e);

        String logfile = System.getProperty("karma.home", System.getProperty("user.home")) + File.separator
                + "logs" + File.separator + "karma-default.log";

        System.out.println("Something went BOOM inside of Karma.");
        System.out.println("Details: " + (e.getMessage() != null ? e.getMessage() : e.getClass().getName()));
        System.out.println("See the log file (" + logfile + ") for more information.");
        System.out.println(
                "Please report recurring problems to the Karma developers (http://sourceforge.net/tracker/?group_id=98766).");
        System.out.println("We apologize for the inconvenience.");
        System.out.println();

        System.exit(1);
    }
}