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:com.digitalizat.user.dao.UserDAOImpl.java

@Override
public User getUser(Integer id) throws Exception {
    User user = (User) sessionFactory.getCurrentSession().load(User.class, id);
    if (null == user) {
        throw new Exception("El usuario no existe");
    }/* w w  w.java2 s  . c  om*/
    return user;
}

From source file:com.liferay.mobile.android.v62.image.ImageService.java

public JSONObject getImage(long imageId) throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("imageId", imageId);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONObject(0);
}

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

@RequestMapping(value = "/gaji", method = RequestMethod.POST)
public void saveGaji(@RequestBody Gaji gaji) throws Exception {
    if (gaji == null) {
        throw new Exception("User tidak boleh kosong");
    }/*w w w .  j  a va  2  s. c o m*/

    gajiService.save(gaji);
}

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

/**
 * other sql execution/*  w  w  w .java  2  s  . co  m*/
 * @param errMsg 
 * 
 * @param reqQuery
 * @param userDB
 * @param userType
 * @param userEmail
 * @throws SQLException
 * @throws Exception
 */
public static void runPermissionSQLExecution(String errMsg, final RequestQuery reqQuery, final UserDBDAO userDB,
        final String userType, final String userEmail) throws SQLException, Exception {
    if (!PermissionChecker.isExecute(userType, userDB, reqQuery.getSql())) {
        throw new Exception(errMsg);
    }
    if (reqQuery.getSqlType() == SQL_TYPE.DDL) {
        if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDdl_lock())) {
            throw new Exception(errMsg);
        }
    }
    PublicTadpoleDefine.QUERY_DML_TYPE queryType = reqQuery.getSqlDMLType();
    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);
        }
    }

    runSQLOther(reqQuery, userDB, userType, userEmail);
}

From source file:com.hg.development.apps.messagenotifier_v1.Utils.Utility.java

/**
 * Valider l'adresse IP avec l'expression rgulire.
 * @param ip adresse ip de validation/* ww w.j  a  v a 2 s .c  o  m*/
 * @return <i>true</i> adresse IP valide, adresse IP non valide <i>false</i>
 * @throws Exception
 */
public static boolean validate_ip(final String ip) throws Exception {
    try {
        pattern_IP = Pattern.compile(IPADDRESS_PATTERN);
        matcher = pattern_IP.matcher(ip);

        boolean isMatch = matcher.matches();

        if (!isMatch)
            throw new Exception("Adresse IP non valide !");

        return isMatch;
    } catch (Exception ex) {
        throw ex;
    }
}

From source file:com.mgatelabs.bytemapper.support.definitions.FormatDefinition.java

public void sanity() throws Exception {
    if (tags.isEmpty()) {
        throw new Exception("Format does not contain any custom tags");
    } else {/*from ww w.ja  v a2  s  .  co  m*/
        for (TagDefinition tag : tags) {
            if (tag.getIdentity() <= 0) {
                throw new Exception("The defined tag " + tag.getName() + " has an identity number < 0");
            }
        }
    }
}

From source file:data.dao.CarOptionValueDao.java

public List<CarOptionValue> getUniqueOptionNames(Long ccoId) throws Exception {
    if (ccoId == null) {
        throw new Exception("ccoId is null!");
    }//from   ww  w.  j  a  v  a 2  s . c om
    List<CarOptionValue> res = new ArrayList();
    if (!ccoId.equals((long) 0)) {
        CarCompletionOption cco = carCompletionOptionDao.find(ccoId);
        if (cco != null) {
            String hql = "select distinct cov from CarOptionValue cov where cov.CCO.ccoId=:ccoId group by cov.description order by cov.description";
            Query query = currentSession().createQuery(hql).setParameter("ccoId", ccoId);
            res = query.list();
        }
    } else if (ccoId.equals((long) 0)) {
        String hql = "select cov from CarOptionValue cov group by cov.description,cov.CCO.ccoId order by cov.CCO.uid,cov.CCO.title,cov.description";
        Query query = currentSession().createQuery(hql);
        res = query.list();
    }
    //throw new Exception("size="+res.size()+"; ");
    return res;
}

From source file:com.linkedin.helix.examples.BootstrapProcess.java

public static void main(String[] args) throws Exception {
    String zkConnectString = "localhost:2181";
    String clusterName = "storage-integration-cluster";
    String instanceName = "localhost_8905";
    String file = null;//  w  w  w  .  ja  v  a2  s .c o m
    String stateModelValue = "MasterSlave";
    int delay = 0;
    boolean skipZeroArgs = true;// false is for dev testing
    if (!skipZeroArgs || args.length > 0) {
        CommandLine cmd = processCommandLineArgs(args);
        zkConnectString = cmd.getOptionValue(zkServer);
        clusterName = cmd.getOptionValue(cluster);

        String host = cmd.getOptionValue(hostAddress);
        String portString = cmd.getOptionValue(hostPort);
        int port = Integer.parseInt(portString);
        instanceName = host + "_" + port;

        file = cmd.getOptionValue(configFile);
        if (file != null) {
            File f = new File(file);
            if (!f.exists()) {
                System.err.println("static config file doesn't exist");
                System.exit(1);
            }
        }

        stateModelValue = cmd.getOptionValue(stateModel);
        if (cmd.hasOption(transDelay)) {
            try {
                delay = Integer.parseInt(cmd.getOptionValue(transDelay));
                if (delay < 0) {
                    throw new Exception("delay must be positive");
                }
            } catch (Exception e) {
                e.printStackTrace();
                delay = 0;
            }
        }
    }
    // Espresso_driver.py will consume this
    System.out.println("Starting Process with ZK:" + zkConnectString);

    BootstrapProcess process = new BootstrapProcess(zkConnectString, clusterName, instanceName, file,
            stateModelValue, delay);

    process.start();
    Thread.currentThread().join();
}

From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.utils.TableColumnObjectQuery.java

/**
 * modify table column type //from ww w  .j  a va  2  s.co  m
 * 
 * @param userDB
 * @param tableDAO
 * @param metaDataDao
 * @param strTypeName
 * @return
 */
public static RequestResultDAO modifyColumnType(final UserDBDAO userDB, TableDAO tableDAO,
        TableColumnUpdateDAO metaDataDao) throws Exception {
    RequestResultDAO resultDao = null;
    if (userDB.getDBDefine() == DBDefine.MYSQL_DEFAULT | userDB.getDBDefine() == DBDefine.MARIADB_DEFAULT) {
        // ALTER TABLE ? MODIFY ? 
        String strQuery = String.format("ALTER TABLE %s CHANGE %s %s %s", tableDAO.getSysName(),
                metaDataDao.getColumnName(), metaDataDao.getColumnName(), metaDataDao.getDataType());
        resultDao = ExecuteDDLCommand.executSQL(userDB, strQuery);

    } else {
        throw new Exception("Not support rename table.");
    }

    return resultDao;
}

From source file:nz.co.senanque.validationengine.LocaleAwareExceptionFactory.java

public Exception getException(String message, Object... args) {
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource);
    String localisedMessage = messageSourceAccessor.getMessage(message, args);
    return new Exception(localisedMessage);
}