Example usage for java.lang Exception Exception

List of usage examples for java.lang Exception Exception

Introduction

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

Prototype

public Exception(Throwable cause) 

Source Link

Document

Constructs a new exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:geotag.example.sbickt.SbicktAPI.java

public static Queue<GeoTag> getGeoTags(Point3D me) throws Exception {
    KmlParser kp = new KmlParser();
    Queue<GeoTag> listOfGeoTags = new LinkedList<GeoTag>();
    Exception up = new Exception("SbicktAPI -> getGeoTags: No data from server");

    kp.requestKml(Properties.URL_PROTOCOL, Properties.URL_HOST, Properties.URL_PORT,
            Properties.URL_FOLDER_LIST + "?lat=" + me.x + "&lng=" + me.y);

    listOfGeoTags = kp.generateObjects();

    if (listOfGeoTags == null) {
        throw up; //ha ha
    } else if (listOfGeoTags.isEmpty()) {
        throw new Exception("SbicktAPI -> getGeoTags: Object list is empty");
    } else {/*from   w  w  w. j  a  v  a  2 s . co  m*/
        return listOfGeoTags;
    }
}

From source file:it.attocchi.jsf2.PageBaseAuth.java

@Override
protected final void init() throws Exception {

    if (isUtenteLoggato()) {
        initLogged();/*ww  w. j a va2s. co  m*/
    } else {
        logger.warn("Necessaria Autenticazione");
        initNonLogged();
        throw new Exception("Necessaria Autenticazione");
    }
}

From source file:logica.SesionLogica.java

@Override
public Jefe iniciarSesionJefe(Integer documento, String clave) throws Exception {
    Jefe j = jefeDAO.find(documento);/*  ww  w . jav a 2  s  .c o m*/
    if (j != null) {
        String claveEncriptada = DigestUtils.md5Hex(clave);
        if (!j.getIngsoftware().getClave().equals(claveEncriptada)) {
            throw new Exception("La clave es incorrecta.");
        }
    }
    return j;
}

From source file:com.mirth.connect.connectors.mllp.ResponseAck.java

public ResponseAck(String ackMessageString) {
    // save the incoming ack message
    this.ackMessageString = ackMessageString;

    try {//from  w ww.jav  a 2s.  c o  m
        if (ackMessageString.startsWith("<")) {
            HL7v2Header headerData = HL7v2XMLQuickParser.getInstance().processMSA(ackMessageString);
            if (headerData.getParseError() == null) {
                setStatus(headerData.getAcknowledgmentCode(), headerData.getAckMessageControlId(),
                        headerData.getAckTextMessage(), headerData.getError());
            } else {
                throw new Exception(headerData.getParseError());
            }
        } else {
            char segmentDelim = '\r';
            char fieldDelim = ackMessageString.charAt(3); // Usually |

            Pattern segmentPattern = Pattern.compile(Pattern.quote(String.valueOf(segmentDelim)));
            Pattern fieldPattern = Pattern.compile(Pattern.quote(String.valueOf(fieldDelim)));

            String msa1 = "";
            String msa2 = "";
            String msa3 = "";
            String err1 = "";
            String[] segments = segmentPattern.split(ackMessageString);
            for (String segment : segments) {
                String[] fields = fieldPattern.split(segment);

                if (fields[0].equals("MSA")) {
                    if (fields.length > 1) {
                        msa1 = fields[1];
                    }
                    if (fields.length > 3) {
                        msa3 = fields[3];
                    }
                } else if (fields[0].equals("ERR")) {
                    if (fields.length > 1) {
                        err1 = fields[1];
                    }
                }
            }

            setStatus(msa1, msa2, msa3, err1);
        }

        logger.debug("ACK: " + ackMessageString);
    } catch (Exception e) {
        errorDescription = " Message is not a valid ACK";
        errorDescription += "\n" + e + "\n" + ackMessageString;
    }
}

From source file:net.sf.jdbcwrappers.spring.DataSourceWrapperFactory.java

public void afterPropertiesSet() throws Exception {
    if (wrapperFactory == null) {
        throw new Exception("wrapperFactory not set");
    }/*  w  w w .  j  av a  2  s. co  m*/
    if (dataSource == null) {
        throw new Exception("dataSource not set");
    }
    wrappedDataSource = wrapperFactory.wrapDataSource(dataSource);
}

From source file:SaveCapturedAudioMIDlet.java

public SaveCapturedAudioMIDlet() {
    display = Display.getDisplay(this);

    alert.setTimeout(Alert.FOREVER);//www.jav a  2s  .c  o  m
    alert.setString("Capturing for 10 seconds.");

    alert.addCommand(exitCommand);
    alert.setCommandListener(this);

    try {
        capturePlayer = Manager.createPlayer("capture://audio");
        if (capturePlayer != null) {
            capturePlayer.realize();
            display.setCurrent(alert);
            if (rControl == null)
                throw new Exception("No RecordControl available");
            rControl.setRecordLocation("file:///test.wav");
        } else {
            throw new Exception("Capture Audio Player is not available");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.hangum.tadpole.rdb.core.editors.main.execute.sub.ExecuteBatchSQL.java

/**
 * select? execute  .//from www .ja  va 2  s  .c  o  m
 * @param errMsg 
 * 
 * @param listQuery
 * @param reqQuery
 * @param userDB
 * @param userType
 * @param intCommitCount
 * @param userEmail
 * @throws Exception
 */
public static void runSQLExecuteBatch(String errMsg, List<String> listQuery, final RequestQuery reqQuery,
        final UserDBDAO userDB, final String userType, final int intCommitCount, final String userEmail)
        throws Exception {
    if (!PermissionChecker.isExecute(userType, userDB, listQuery)) {
        throw new Exception(errMsg);
    }
    // Check the db access control 
    for (String strQuery : listQuery) {
        if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDdl_lock())) {
            throw new Exception(errMsg);
        }

        PublicTadpoleDefine.QUERY_DML_TYPE queryType = SQLUtil.sqlQueryType(strQuery);
        if (reqQuery.getSqlType() == SQL_TYPE.DDL) {
            if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDdl_lock())) {
                throw new Exception(errMsg);
            }
        }
        if (queryType == QUERY_DML_TYPE.INSERT) {
            if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getInsert_lock())) {
                throw new Exception(errMsg);
            }
        }
        if (queryType == QUERY_DML_TYPE.UPDATE) {
            if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getUpdate_lock())) {
                throw new Exception(errMsg);
            }
        }
        if (queryType == QUERY_DML_TYPE.DELETE) {
            if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDelete_locl())) {
                throw new Exception(errMsg);
            }
        }
    }

    java.sql.Connection javaConn = null;
    Statement statement = null;

    try {
        if (reqQuery.isAutoCommit()) {
            SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
            javaConn = client.getDataSource().getConnection();
        } else {
            javaConn = TadpoleSQLTransactionManager.getInstance(userEmail, userDB);
        }
        statement = javaConn.createStatement();

        int count = 0;
        for (String strQuery : listQuery) {
            //  ? commit? rollback?    ???
            if (!TransactionManger.calledCommitOrRollback(reqQuery.getSql(), userEmail, userDB)) {

                if (StringUtils.startsWithIgnoreCase(strQuery.trim(), "CREATE TABLE")) { //$NON-NLS-1$
                    strQuery = StringUtils.replaceOnce(strQuery, "(", " ("); //$NON-NLS-1$ //$NON-NLS-2$
                }

            }
            statement.addBatch(strQuery);

            if (++count % intCommitCount == 0) {
                statement.executeBatch();
                count = 0;
            }
        }
        statement.executeBatch();
    } catch (Exception e) {
        logger.error("Execute batch update", e); //$NON-NLS-1$
        throw e;
    } finally {
        try {
            statement.close();
        } catch (Exception e) {
        }

        if (reqQuery.isAutoCommit()) {
            try {
                javaConn.close();
            } catch (Exception e) {
            }
        }
    }
}

From source file:com.liferay.mobile.android.v62.portlet.PortletService.java

public JSONArray getWarPortlets() throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  ww  w .  j a v a 2s . c o m*/
        JSONObject _params = new JSONObject();

        _command.put("/portlet/get-war-portlets", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.artivisi.salary.payroll.system.controller.KaryawanController.java

@RequestMapping(value = "/karyawan/{id}", method = RequestMethod.GET)
public Karyawan findKaryawanById(@PathVariable String id) throws Exception {
    Karyawan karyawan = karyawanService.findOne(id);
    if (karyawan == null) {
        throw new Exception("Data tidak ditemukan");
    }//  w  ww.j  av  a  2 s.c om
    return karyawanService.findOne(id);
}

From source file:com.oasis.test.truck.TruckStatusRecordTest.java

@Test
public void update() throws Exception {
    TruckStatusRecordSO so = new TruckStatusRecordSO();
    so.setLicensePlate("licensePlate");
    PageList<TruckStatusRecordVO> page = service.getPageList(so);
    if (page.getFullListSize() > 0) {
        TruckStatusRecordVO vo = service.findTruckStatusRecord(page.getList().get(0).getId());
        vo.setLicensePlate("licensePlate1");
        service.updateTruckStatusRecord(vo);
    } else {// w ww  .ja v a  2 s. co m
        throw new Exception("getPageList() error!");
    }
}