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.ea.core.orm.handle.impl.UpdateORMHandle.java

@Override
protected Object execute(ORMParamsDTO dto) throws Exception {
    Object po = dto.getParam();//  w  w w  .  j a  va 2 s. c om
    if (po instanceof BasePO) {
        Session session = this.getHibernateSessionFactory().getCurrentSession();
        session.update(po);
        return null;
    } else {
        throw new Exception("??BasePO!");
    }

}

From source file:com.w20e.socrates.workflow.MappingFactory.java

/**
 * Create a new Mapping object. This will only work if the
 * attributes provided as argument contains a non-null, non-empty
 * value for 'from', 'to' and 'condition'.
 *
 * @param attrs an <code>Attributes</code> value
 * @return an <code>Object</code> value
 * @exception Exception if an error occurs
 *//*  w  ww . j  av  a 2s.  c  o  m*/
public final Mapping createObject(final Attributes attrs) throws Exception {

    if (attrs.getValue("from") == null || attrs.getValue("to") == null || attrs.getValue("condition") == null
            || "".equals(attrs.getValue("from")) || "".equals(attrs.getValue("to"))
            || "".equals(attrs.getValue("condition"))) {
        throw new Exception("No from, to or condition specified!");
    }

    return new Mapping(ActionFactory.getAction(attrs.getValue("from")),
            ActionFactory.getAction(attrs.getValue("to")), attrs.getValue("condition"));
}

From source file:com.spstudio.session.filter.SessionAOP.java

@Around(value = "@annotation(com.spstudio.session.UserSession)")
public Object aroundManager(ProceedingJoinPoint pj) throws Exception {
    HttpServletRequest request = SysContent.getRequest();
    HttpServletResponse response = SysContent.getResponse();
    HttpSession session = SysContent.getSession();

    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";

    UserSessionType type = this.getSessionType(pj);
    if (type == null) {
        throw new Exception("The value of NeedSession is must.");
    }//w  ww.jav a2  s.co  m

    Object uobj = session.getAttribute("user");
    Object mobj = session.getAttribute("manager");

    boolean isUser = type == UserSessionType.USER && uobj != null;
    boolean isManager = type == UserSessionType.MANAGER && mobj != null;
    boolean isUserOrManager = type == UserSessionType.OR && (mobj != null || uobj != null);
    try {
        if (isUser || isManager || isUserOrManager) {
            return pj.proceed();
        } else { // ?session  
            if (request.getHeader("x-requested-with") != null
                    && request.getHeader("x-requested-with").equalsIgnoreCase( //ajax?       
                            "XMLHttpRequest")) {
                response.addHeader("sessionstatus", "timeout");
                // EasyUi  
                //response.getWriter().print("{\"rows\":[],\"success\":false,\"total\":0}");       
            } else {//http?       
                response.sendRedirect(basePath + "error/nosession");
            }
        }
    } catch (Throwable e) {
        // TODO Auto-generated catch block  
        e.printStackTrace();
    }
    return null;
}

From source file:net.sf.jabref.groups.structure.SearchGroup.java

/**
 * Parses s and recreates the SearchGroup from it.
 *
 * @param s The String representation obtained from
 *          SearchGroup.toString(), or null if incompatible
 *//*w w w  .j  av  a2s  .co  m*/
public static AbstractGroup fromString(String s, BibDatabase db, int version) throws Exception {
    if (!s.startsWith(SearchGroup.ID)) {
        throw new Exception("Internal error: SearchGroup cannot be created from \"" + s + "\". "
                + "Please report this on https://github.com/JabRef/jabref/issues");
    }
    QuotedStringTokenizer tok = new QuotedStringTokenizer(s.substring(SearchGroup.ID.length()),
            AbstractGroup.SEPARATOR, AbstractGroup.QUOTE_CHAR);
    switch (version) {
    case 0:
    case 1:
    case 2: {
        String name = tok.nextToken();
        String expression = tok.nextToken();
        boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
        boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
        // version 0 contained 4 additional booleans to specify search
        // fields; these are ignored now, all fields are always searched
        return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR),
                StringUtil.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
                GroupHierarchyType.INDEPENDENT);
    }
    case 3: {
        String name = tok.nextToken();
        int context = Integer.parseInt(tok.nextToken());
        String expression = tok.nextToken();
        boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
        boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
        // version 0 contained 4 additional booleans to specify search
        // fields; these are ignored now, all fields are always searched
        return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR),
                StringUtil.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
                GroupHierarchyType.getByNumber(context));
    }
    default:
        throw new UnsupportedVersionException("SearchGroup", version);
    }
}

From source file:com.blogspot.jadecalyx.webtools.jcAddressIndex.java

private void loadIndexFromJson(String site) throws Exception {

    String s = System.getProperty("file.separator");
    String runPath = System.getProperty("user.dir");
    String fullPath = String.join(s, runPath, "SiteInfo", site, "AddressInfo", "addresses.json");
    File f = new File(fullPath);
    if (!f.isFile()) {
        throw new Exception(String.format("loadIndex unable to find file for site: %s", site));
    }//  ww w .j  a va 2  s. co m

    //load json file
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(new FileReader(fullPath));
    JSONObject jsonObject = (JSONObject) obj;
    JSONArray addressList = (JSONArray) jsonObject.get("address-list");

    for (int i = 0; i < addressList.size(); i++) {
        JSONObject address = (JSONObject) addressList.get(i);
        _addresses.put(address.get("handle").toString(),
                new jcAddressSet(address.get("segment").toString(), address.get("mask").toString()));
    }

}

From source file:com.kimbrelk.privileges.User.java

public User(JSONObject json, int version) throws Exception {
    if (fromJSON(json, version).hasFailed())
        throw new Exception("Conversion from JSON failed.");
}

From source file:com.liferay.mobile.android.v7.app.AppService.java

public JSONObject deleteApp(long appId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  www .j  ava2 s.  c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("appId", appId);

        _command.put("/marketplace.app/delete-app", _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.AbsensiController.java

@RequestMapping(value = "/absensi/findByNip/{nip}", method = RequestMethod.GET)
public Absensi findAbsensiByNip(@PathVariable String nip) throws Exception {
    Absensi absensi = absensiService.findAbsensiByNip(nip);
    if (absensi == null) {
        throw new Exception("Data tidak ditemukan");
    }/*ww w . ja  v a  2s .  c  o  m*/
    return absensi;
}

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

@RequestMapping(value = "/jabatan", method = RequestMethod.POST)
public void saveJabatan(@RequestBody Jabatan jabatan) throws Exception {
    if (jabatan == null) {
        throw new Exception("User tidak boleh kosong");
    }/*from   w w  w.  ja  v  a2 s  . c o  m*/

    jabatanService.save(jabatan);
}

From source file:org.taverna.server.master.localworker.LocalWorkerFactory.java

@Bean(name = "localworker.factory")
AbstractRemoteRunFactory getLocalworkerFactory(@Value("${backEndFactory}") String mode) throws Exception {
    if (mode == null || mode.isEmpty() || mode.startsWith("${"))
        throw new Exception("no value for ${backEndFactory}");
    Class<?> c = Class.forName(mode);
    if (AbstractRemoteRunFactory.class.isAssignableFrom(c))
        return (AbstractRemoteRunFactory) c.newInstance();
    throw new Exception("unknown remote run factory: " + mode);
}