Example usage for java.util MissingResourceException printStackTrace

List of usage examples for java.util MissingResourceException printStackTrace

Introduction

In this page you can find the example usage for java.util MissingResourceException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:net.sourceforge.seqware.pipeline.deciders.BasicDecider.java

@Override
/**//from ww w .  jav a  2s . c  o  m
 * This method is intended to be called AFTER any implementing class's init
 * method.
 */
public ReturnValue init() {

    if (!(options.has("study-name") ^ options.has("sample-name") ^ options.has("sequencer-run-name")
            ^ options.has("all"))) {
        Log.stdout(this.get_syntax());
        Log.error("Please provide one of sample-name, study-name, sequencer-run-name or all");
        ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    }

    try {
        ResourceBundle rb = PropertyResourceBundle.getBundle("decider");
        String parents = rb.getString("parent-workflow-accessions");
        String checks = rb.getString("check-wf-accessions");
        String wfa = rb.getString("workflow-accession");
        if (wfa != null && !wfa.trim().isEmpty()) {
            this.setWorkflowAccession(wfa);
        }
        if (parents != null && !parents.trim().isEmpty()) {
            List<String> pas = Arrays.asList(parents.split(","));
            this.setParentWorkflowAccessions(new TreeSet(pas));
        }
        if (checks != null && !checks.trim().isEmpty()) {
            List<String> cwa = Arrays.asList(checks.split(","));
            this.setWorkflowAccessionsToCheck(new TreeSet(cwa));

        }
    } catch (MissingResourceException e) {
        Log.debug("No decider resource found: ", e);
    }

    //Group-by allows you to group processing events based on one characteristic.
    //Normally, this allows you to run on a group of samples (for example, all
    //of the IUS-level BAM files). The default is no grouping, so the workflow
    //will be run independently on every file it finds
    if (options.has("group-by")) {
        String headerString = (String) options.valueOf("group-by");
        try {
            header = Header.valueOf(headerString);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            StringBuilder sb = new StringBuilder();
            sb.append("group-by attribute must be one of the following: \n");
            for (Header h : Header.values()) {
                sb.append("\t").append(h.name()).append("\n");

            }
            Log.stdout(sb.toString());
            ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
        }
    }

    if (options.has("wf-accession")) {
        workflowAccession = (String) options.valueOf("wf-accession");
    } else if (workflowAccession == null) {
        Log.error("Must specify the workflow-accession of the workflow to run");
        ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    }

    // Check for filtering on the files. Either parent workflow accessions
    // or file meta-types, or both
    boolean hasFilter = false;
    if (options.has("parent-wf-accessions")) {
        String pas = (String) options.valueOf("parent-wf-accessions");
        for (String p : pas.split(",")) {
            parentWorkflowAccessions.add(p.trim());
            hasFilter = true;
        }
    }
    if (options.has("meta-types")) {
        String mt = (String) options.valueOf("meta-types");
        metaTypes = Arrays.asList(mt.split(","));
        hasFilter = true;
    }

    if (!hasFilter && parentWorkflowAccessions.isEmpty() && metaTypes == null) {
        Log.error("You must run a decider with parent-wf-accessions or meta-types (or both).");
        ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    }

    //Repeat-checking options. if present, check-wf-accessions will check to
    //see if the samples have been run through a particular workflow before.
    //These workflows will not be launched again
    //Optionally you can force the decider to re-run all possibilities in
    //the database with force-run-all.
    if (options.has("check-wf-accessions")) {

        String pas = (String) options.valueOf("check-wf-accessions");
        Log.debug("Pas = " + pas);
        if (pas.contains(",")) {
            for (String p : pas.split(",")) {
                workflowAccessionsToCheck.add(p.trim());
            }
        } else {
            workflowAccessionsToCheck.add(pas.trim());
        }
        //Separate out this logic
        //workflowAccessionsToCheck.add(workflowAccession);
    }
    if (forceRunAll == null) {
        forceRunAll = options.has("force-run-all");
    }

    //test turns off all of the submission functions and just prints to stdout
    if (test == null) {
        test = options.has("test");
    }
    if (test) {
        StringWriter writer = new StringWriter();
        try {
            FindAllTheFiles.printHeader(writer, true);
            Log.stdout(writer.toString());
        } catch (IOException ex) {
            Log.error(ex);
        }
    }

    if (skipStuff == null) {
        skipStuff = !options.has("ignore-skip-flag");
    }

    if (metadataWriteback == null) {
        metadataWriteback = !(options.has("no-metadata") || options.has("no-meta-db"));
    }

    if (runNow == null) {
        if (options.has("schedule")) {
            runNow = false;
        } else {
            runNow = true;
        }
    }

    LocalhostPair localhostPair = FileTools.getLocalhost(options);
    String localhost = localhostPair.hostname;
    if (host == null) {
        if (options.has("host") || options.has("ho")) {
            host = (String) options.valueOf("host");
        } else {
            host = localhost;
        }
    }
    if (localhostPair.returnValue.getExitStatus() != ReturnValue.SUCCESS && host == null) {
        Log.error("Could not determine localhost: Return value " + localhostPair.returnValue.getExitStatus());
        Log.error("Please supply it on the command line with --host");
        ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    } else if (!host.equals(localhost)) {
        Log.warn("The localhost and the scheduling host are not the same: " + localhost + " and " + host
                + ". Proceeding anyway.");
    }

    if (options.has("launch-max")) {
        try {
            launchMax = Integer.parseInt(options.valueOf("launch-max").toString());
        } catch (NumberFormatException e) {
            Log.error("The launch-max parameter must be an integer. Unparseable integer: "
                    + options.valueOf("launch-max").toString());
            ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
        }
    }

    if (options.has("rerun-max")) {
        try {
            rerunMax = Integer.parseInt(options.valueOf("rerun-max").toString());
        } catch (NumberFormatException e) {
            Log.error("The rerun-max parameter must be an integer. Unparseable integer: "
                    + options.valueOf("rerun-max").toString());
            ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
        }
    }

    if (workflowAccession == null || "".equals(workflowAccession)) {
        Log.error("The wf-accession must be defined.");
        ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    }

    if (metadata instanceof MetadataDB) {
        metaws = new MetadataWS();
        ret = metaws.init(config.get("SW_REST_URL"), config.get("SW_REST_USER"), config.get("SW_REST_PASS"));
    } else if (metadata instanceof MetadataWS) {
        metaws = (MetadataWS) metadata;
        //metadb = new MetadataDB();
        //String connection = "jdbc:postgresql://" + config.get("SW_DB_SERVER") + "/" + config.get("SW_DB");
        //ret = metadb.init(connection, config.get("SW_DB_USER"), config.get("SW_DB_PASS"));
    } else {
        ret.setExitStatus(ReturnValue.DBCOULDNOTINITIALIZE);
    }
    return ret;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validatePartyPhone() {

    String status = "sucess";
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message = new FacesMessage();
    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);
    Matcher m1 = p1.matcher((String) getPhonePartyIpTx().getValue());
    Matcher m2 = p2.matcher((String) getPhonePartyIpTx().getValue());

    try {/*from w ww . ja  va  2 s . c  om*/

        if (getCountryPartySelOneCho() != null && (getCountryPartySelOneCho().getValue().equals("US")
                || getCountryPartySelOneCho().getValue().equals("CA"))) {

            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getPhonePartyIpTx().getClientId(context), message);
                status = "failure";
            }
        }
    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validateNewInstPhone() {

    String status = "sucess";
    FacesMessage message = new FacesMessage();
    FacesContext context = FacesContext.getCurrentInstance();

    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);

    Matcher m1 = p1.matcher((String) getPhoneBusNewInstIpTx().getValue());
    Matcher m2 = p2.matcher((String) getPhoneBusNewInstIpTx().getValue());

    try {/* w ww.  ja  v  a 2 s.  co m*/
        if (getCountryBusNewInstSelOneCho() != null && (getCountryBusNewInstSelOneCho().getValue().equals("US")
                || getCountryBusNewInstSelOneCho().getValue().equals("CA"))) {
            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getPhoneBusNewInstIpTx().getClientId(context), message);
                status = "failure";
            }
        }
    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validateNewInstFax() {

    String status = "sucess";
    FacesMessage message = new FacesMessage();
    FacesContext context = FacesContext.getCurrentInstance();
    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);

    Matcher m1 = p1.matcher((String) getFaxBusNewInstIpTx().getValue());
    Matcher m2 = p2.matcher((String) getFaxBusNewInstIpTx().getValue());

    try {/* ww w.  j ava  2 s.  c o  m*/
        if (getCountryBusNewInstSelOneCho() != null && (getCountryBusNewInstSelOneCho().getValue().equals("US")
                || getCountryBusNewInstSelOneCho().getValue().equals("CA"))) {
            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getFaxBusNewInstIpTx().getClientId(context), message);
                status = "failure";
            }
        }

    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validateHomePhone() {

    String status = "sucess";
    FacesMessage message = new FacesMessage();
    FacesContext context = FacesContext.getCurrentInstance();
    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);

    Matcher m1 = p1.matcher((String) getPhoneHomeIpTx().getValue());
    Matcher m2 = p2.matcher((String) getPhoneHomeIpTx().getValue());

    try {/*from   ww w.  j  av  a2s. co m*/
        if (getCountryHomeSelOneCho() != null && (getCountryHomeSelOneCho().getValue().equals("US")
                || getCountryHomeSelOneCho().getValue().equals("CA"))) {
            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getPhoneHomeIpTx().getClientId(context), message);
                status = "failure";
            }
        }

    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validateHomeFax() {

    String status = "sucess";
    FacesMessage message = new FacesMessage();
    FacesContext context = FacesContext.getCurrentInstance();
    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);

    Matcher m1 = p1.matcher((String) getFaxHomeIpTx().getValue());
    Matcher m2 = p2.matcher((String) getFaxHomeIpTx().getValue());

    try {/*from w w w  .  jav  a2  s . c  o m*/

        if (getCountryHomeSelOneCho() != null && (getCountryHomeSelOneCho().getValue().equals("US")
                || getCountryHomeSelOneCho().getValue().equals("CA"))) {
            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getFaxHomeIpTx().getClientId(context), message);
                status = "failure";
            }
        }

    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:org.cap.selfService.selfRegistration.ui.bean.ContactDetailsBackingBean.java

public String validateReqFlds() {
    FacesContext context = FacesContext.getCurrentInstance();

    String status = "sucess";
    try {//w  w  w. j a v  a 2  s .  c  om
        if (getAddressOptionsRdBtn().getValue().equals("business")
                || (getAddressOptionsRdBtn().getValue().equals("businesshome"))) {
            if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {

                if (getPartyNameIpLOV().getValue() == null
                        || (getPartyNameIpLOV().getValue() != null
                                && getPartyNameIpLOV().getValue().toString().trim().equals(""))
                        || (getPartyNameIpLOV().getValue() != null
                                && getPartyNameIpLOV().getValue().toString().trim().equals(""))) {

                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_INSTNAME_REQ"));
                    context.addMessage(getPartyNameIpLOV().getClientId(context), message);
                } else {
                    if (getAddress1PartyIpTx().getValue() == null || (getAddress1PartyIpTx().getValue() != null
                            && getAddress1PartyIpTx().getValue().toString().trim().equals(""))) {

                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_ADDR1_REQ"));
                        context.addMessage(getAddress1PartyIpTx().getClientId(context), message);
                    }
                    if (getCountryPartySelOneCho().getValue() == null
                            || (getCountryPartySelOneCho().getValue() != null
                                    && getCountryPartySelOneCho().getValue().equals(""))) {

                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_COUNTRY_REQ"));
                        context.addMessage(getCountryPartySelOneCho().getClientId(context), message);
                    }
                    if (getCityPartyIpTx().getValue() == null || (getCityPartyIpTx().getValue() != null
                            && getCityPartyIpTx().getValue().toString().trim().equals(""))) {

                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_CITY_REQ"));
                        context.addMessage(getCityPartyIpTx().getClientId(context), message);
                    }
                    if (getPhonePartyIpTx().getValue() == null || (getPhonePartyIpTx().getValue() != null
                            && getPhonePartyIpTx().getValue().toString().trim().equals(""))) {

                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_PHONE_REQ"));
                        context.addMessage(getPhonePartyIpTx().getClientId(context), message);
                    }

                    if (getPhonePartyIpTx().getValue() != null
                            && !getPhonePartyIpTx().getValue().toString().trim().equals("")) {
                        String phoneStatus = validatePartyPhone();
                        if (phoneStatus.equals("failure")) {
                            status = "failure";
                        }
                    }
                    if (getFaxPartyIpTx().getValue() != null
                            && !getFaxPartyIpTx().getValue().toString().trim().equals("")) {
                        String faxStatus = validatePartyFax();
                        if (faxStatus.equals("failure")) {
                            status = "failure";
                        }
                    }
                    if (getCountryPartySelOneCho().getValue() != null) {

                        if (getCountryPartySelOneCho().getValue().equals("US")) {
                            if (getStatesUSPartySelOneCho().getValue() == null
                                    || (getStatesUSPartySelOneCho().getValue() != null
                                            && getStatesUSPartySelOneCho().getValue().equals(""))) {

                                status = "failure";
                                FacesMessage message = new FacesMessage();
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                context.addMessage(getStatesUSPartySelOneCho().getClientId(context), message);
                            }
                            if (getPostalCodePartyIpTx().getValue() == null
                                    || (getPostalCodePartyIpTx().getValue() != null && getPostalCodePartyIpTx()
                                            .getValue().toString().trim().equals(""))) {

                                status = "failure";
                                FacesMessage message = new FacesMessage();
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                                context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                            }
                        }
                        if (getCountryPartySelOneCho().getValue() != null
                                && getCountryPartySelOneCho().getValue().equals("AU")) {

                            if (getStatesAUPartySelOneCho().getValue() == null
                                    || (getStatesAUPartySelOneCho().getValue() != null
                                            && getStatesAUPartySelOneCho().getValue().equals(""))) {

                                status = "failure";
                                FacesMessage message = new FacesMessage();
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                context.addMessage(getStatesAUPartySelOneCho().getClientId(context), message);
                            }
                        }
                        if (getCountryPartySelOneCho().getValue() != null
                                && getCountryPartySelOneCho().getValue().equals("CA")) {
                            if (getStatesCAPartySelOneCho().getValue() == null
                                    || (getStatesCAPartySelOneCho().getValue() != null
                                            && getStatesCAPartySelOneCho().getValue().equals(""))) {

                                status = "failure";
                                FacesMessage message = new FacesMessage();
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                context.addMessage(getStatesCAPartySelOneCho().getClientId(context), message);
                            }
                            if (getPostalCodePartyIpTx().getValue() == null
                                    || (getPostalCodePartyIpTx().getValue() != null && getPostalCodePartyIpTx()
                                            .getValue().toString().trim().equals(""))) {

                                status = "failure";
                                FacesMessage message = new FacesMessage();
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                                context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                            }
                        }

                        //party zipcode validation
                        if (getPostalCodePartyIpTx().getValue() != null
                                && !getPostalCodePartyIpTx().getValue().toString().trim().equals("")) {
                            FacesMessage message = new FacesMessage();
                            Pattern p4 = Pattern.compile(expr4);
                            Pattern p5 = Pattern.compile(expr5);
                            Matcher m4 = p4.matcher((String) getPostalCodePartyIpTx().getValue());
                            Matcher m5 = p5.matcher((String) getPostalCodePartyIpTx().getValue());
                            if (getCountryPartySelOneCho() != null
                                    && getCountryPartySelOneCho().getValue().equals("US")) {
                                if (!m4.find()) {
                                    message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                    status = "failure";
                                }
                            }
                            if (getCountryPartySelOneCho() != null
                                    && getCountryPartySelOneCho().getValue().equals("CA")) {
                                if (!m5.find()) {
                                    message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                    status = "failure";
                                }
                            }
                        }
                    }
                }
            }
            if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {

                if (getInstitutionNameBusNewInstIpTx().getValue() == null
                        || (getInstitutionNameBusNewInstIpTx().getValue() != null
                                && getInstitutionNameBusNewInstIpTx().getValue().toString().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_INSTNAME_REQ"));
                    context.addMessage(getInstitutionNameBusNewInstIpTx().getClientId(context), message);
                }
                if (getAddress1BusNewInstIpTx().getValue() == null
                        || (getAddress1BusNewInstIpTx().getValue() != null
                                && getAddress1BusNewInstIpTx().getValue().toString().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_ADDR1_REQ"));
                    context.addMessage(getAddress1BusNewInstIpTx().getClientId(context), message);
                }
                if (getCountryBusNewInstSelOneCho().getValue() == null
                        || (getCountryBusNewInstSelOneCho().getValue() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_COUNTRY_REQ"));
                    context.addMessage(getCountryBusNewInstSelOneCho().getClientId(context), message);
                }
                if (getCityBusNewInstIpTx().getValue() == null || (getCityBusNewInstIpTx().getValue() != null
                        && getCityBusNewInstIpTx().getValue().toString().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_CITY_REQ"));
                    context.addMessage(getCityBusNewInstIpTx().getClientId(context), message);
                }
                if (getPhoneBusNewInstIpTx().getValue() == null || (getPhoneBusNewInstIpTx().getValue() != null
                        && getPhoneBusNewInstIpTx().getValue().toString().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("BUS_PHONE_REQ"));
                    context.addMessage(getPhoneBusNewInstIpTx().getClientId(context), message);
                }
                if (getPhoneBusNewInstIpTx().getValue() != null
                        && !getPhoneBusNewInstIpTx().getValue().toString().equals("")) {
                    String phoneStatus = validateNewInstPhone();
                    if (phoneStatus.equals("failure")) {
                        status = "failure";
                    }
                }
                if (getFaxBusNewInstIpTx().getValue() != null
                        && !getFaxBusNewInstIpTx().getValue().toString().equals("")) {
                    String faxStatus = validateNewInstFax();
                    if (faxStatus.equals("failure")) {
                        status = "failure";
                    }
                }
                if (getCountryBusNewInstSelOneCho().getValue().equals("US")) {
                    if (getStatesUSNewInstSelOneCho().getValue() == null
                            || (getStatesUSNewInstSelOneCho().getValue() != null
                                    && getStatesUSNewInstSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                        context.addMessage(getStatesUSNewInstSelOneCho().getClientId(context), message);
                    }
                    if (getPostalCodeBusNewInstIpTx().getValue() == null
                            || (getPostalCodeBusNewInstIpTx().getValue() != null
                                    && getPostalCodeBusNewInstIpTx().getValue().toString().trim().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                        context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                    }
                }
                if (getCountryBusNewInstSelOneCho().getValue().equals("AU")) {
                    if (getStatesAUNewInstSelOneCho().getValue() == null
                            || (getStatesAUNewInstSelOneCho().getValue() != null
                                    && getStatesAUNewInstSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                        context.addMessage(getStatesAUNewInstSelOneCho().getClientId(context), message);
                    }
                }
                if (getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                    if (getStatesCANewInstSelOneCho().getValue() == null
                            || (getStatesCANewInstSelOneCho().getValue() != null
                                    && getStatesCANewInstSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                        context.addMessage(getStatesCANewInstSelOneCho().getClientId(context), message);
                    }
                    if (getPostalCodeBusNewInstIpTx().getValue() == null
                            || (getPostalCodeBusNewInstIpTx().getValue() != null
                                    && getPostalCodeBusNewInstIpTx().getValue().toString().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                        context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                    }
                }
                //new inst zipcode validation
                if (getPostalCodeBusNewInstIpTx().getValue() != null
                        && !getPostalCodeBusNewInstIpTx().getValue().toString().trim().equals("")) {
                    FacesMessage message = new FacesMessage();
                    Pattern p4 = Pattern.compile(expr4);
                    Pattern p5 = Pattern.compile(expr5);
                    Matcher m4 = p4.matcher((String) getPostalCodeBusNewInstIpTx().getValue());
                    Matcher m5 = p5.matcher((String) getPostalCodeBusNewInstIpTx().getValue());
                    if (getCountryBusNewInstSelOneCho() != null
                            && getCountryBusNewInstSelOneCho().getValue().equals("US")) {
                        if (!m4.find()) {
                            message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                            status = "failure";
                        }
                    }
                    if (getCountryBusNewInstSelOneCho() != null
                            && getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                        if (!m5.find()) {
                            message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                            status = "failure";
                        }
                    }
                }
            }
        }
        //home
        if (getAddressOptionsRdBtn().getValue().equals("home")
                || (getAddressOptionsRdBtn().getValue().equals("businesshome"))) {

            if (getAddress1HomeIpTx().getValue() == null || (getAddress1HomeIpTx().getValue() != null
                    && getAddress1HomeIpTx().getValue().toString().trim().equals(""))) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail(resourceBundle.getString("HOME_ADDR1_REQ"));
                context.addMessage(getAddress1HomeIpTx().getClientId(context), message);
            }
            if (getCountryHomeSelOneCho().getValue() == null || (getCountryHomeSelOneCho().getValue() != null
                    && getCountryHomeSelOneCho().getValue().equals(""))) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail(resourceBundle.getString("HOME_COUNTRY_REQ"));
                context.addMessage(getCountryHomeSelOneCho().getClientId(context), message);
            }
            if (getCityHomeIpTx().getValue() == null || (getCityHomeIpTx().getValue() != null
                    && getCityHomeIpTx().getValue().toString().trim().equals(""))) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail(resourceBundle.getString("HOME_CITY_REQ"));
                context.addMessage(getCityHomeIpTx().getClientId(context), message);
            }
            if (getPhoneHomeIpTx().getValue() == null || (getPhoneHomeIpTx().getValue() != null
                    && getPhoneHomeIpTx().getValue().toString().trim().equals(""))) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail(resourceBundle.getString("HOME_PHONE_REQ"));
                context.addMessage(getPhoneHomeIpTx().getClientId(context), message);
            }
            if (getPhoneHomeIpTx().getValue() != null
                    && !getPhoneHomeIpTx().getValue().toString().trim().equals("")) {
                String phoneStatus = validateHomePhone();
                if (phoneStatus.equals("failure")) {
                    status = "failure";
                }
            }
            if (getFaxHomeIpTx().getValue() != null
                    && !getFaxHomeIpTx().getValue().toString().trim().equals("")) {
                String faxStatus = validateHomeFax();
                if (faxStatus.equals("failure")) {
                    status = "failure";
                }
            }
            if (getCountryHomeSelOneCho().getValue().equals("US")) {
                if (getStatesUSHomeSelOneCho().getValue() == null
                        || (getStatesUSHomeSelOneCho().getValue() != null
                                && getStatesUSHomeSelOneCho().getValue().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                    context.addMessage(getStatesUSHomeSelOneCho().getClientId(context), message);
                }
                if (getPostalCodeHomeIpTx().getValue() == null || (getPostalCodeHomeIpTx().getValue() != null
                        && getPostalCodeHomeIpTx().getValue().toString().trim().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_ZIP_REQ"));
                    context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                }
            }
            if (getCountryHomeSelOneCho().getValue().equals("AU")) {
                if (getStatesAUHomeSelOneCho().getValue() == null
                        || (getStatesAUHomeSelOneCho().getValue() != null
                                && getStatesAUHomeSelOneCho().getValue().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                    context.addMessage(getStatesAUHomeSelOneCho().getClientId(context), message);
                }
            }
            if (getCountryHomeSelOneCho().getValue().equals("CA")) {
                if (getStatesCAHomeSelOneCho().getValue() == null
                        || (getStatesCAHomeSelOneCho().getValue() != null
                                && getStatesCAHomeSelOneCho().getValue().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                    context.addMessage(getStatesCAHomeSelOneCho().getClientId(context), message);
                }
                if (getPostalCodeHomeIpTx().getValue() == null || (getPostalCodeHomeIpTx().getValue() != null
                        && getPostalCodeHomeIpTx().getValue().toString().trim().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_ZIP_REQ"));
                    context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                }
            }
            //home zipcode validation
            if (getPostalCodeHomeIpTx().getValue() != null
                    && !getPostalCodeHomeIpTx().getValue().toString().trim().equals("")) {
                FacesMessage message = new FacesMessage();
                Pattern p4 = Pattern.compile(expr4);
                Pattern p5 = Pattern.compile(expr5);
                Matcher m4 = p4.matcher((String) getPostalCodeHomeIpTx().getValue());
                Matcher m5 = p5.matcher((String) getPostalCodeHomeIpTx().getValue());
                if (getCountryHomeSelOneCho() != null && getCountryHomeSelOneCho().getValue().equals("US")) {
                    if (!m4.find()) {

                        message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                        status = "failure";
                    }
                }
                if (getCountryHomeSelOneCho() != null && getCountryHomeSelOneCho().getValue().equals("CA")) {
                    if (!m5.find()) {
                        message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                        status = "failure";
                    }
                }
            }
        }
        //businesshome
        if ((getAddressOptionsRdBtn().getValue().equals("businesshome"))) {
            if (getAddressPreferenceRdBtn().getValue() == null) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail(resourceBundle.getString("ADDR_OPTIONS_REQ"));
                context.addMessage(getAddressPreferenceRdBtn().getClientId(context), message);
            }
        }
        if (getLicenseNumberIpTx().getValue() != null && !getLicenseNumberIpTx().getValue().equals("")) {
            String expression = "^[A-Za-z][A-Za-z][0-9]{1,20}$";
            Pattern p1 = Pattern.compile(expression);
            Matcher m1 = p1.matcher((String) getLicenseNumberIpTx().getValue());
            if (!m1.find()) {
                status = "failure";
                FacesMessage message = new FacesMessage();
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                message.setDetail("Please enter the proper value");
                context.addMessage(getLicenseNumberIpTx().getClientId(context), message);
            }
        }
    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    } catch (Exception e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Create the application./*  ww w.  j  a v a2s.c  o  m*/
 * 
 * @throws ConfigReadWriteException
 * @throws IOException
 */
public MainCommGUI() throws IOException, ConfigReadWriteException {
    lg = SpxPcloggerProgramConfig.LOGGER;
    setDefaultLookAndFeelDecorated(isDefaultLookAndFeelDecorated());
    // Konfiguration aus der Datei einlesen
    // bercksichtigt schon per CLI angegebene Werte als gesetzt
    new ReadConfig();
    makeLogger();
    //
    // gib ein paar informationen
    //
    lg.info("Operating System: <" + OperatingSystemDetector.getOsName() + ">");
    lg.info("Java VM Datamodel: " + OperatingSystemDetector.getDataModel() + " bits");
    lg.info("Java VM Datamodel: <" + OperatingSystemDetector.getArch() + ">");
    //
    // Grundstzliche Sachen einstellen
    //
    try {
        ResourceBundle.clearCache();
        if (SpxPcloggerProgramConfig.langCode != null) {
            lg.info("try make locale from cmd options <" + SpxPcloggerProgramConfig.langCode + ">...");
            programLocale = new Locale(SpxPcloggerProgramConfig.langCode);
        } else {
            lg.debug("try get locale from system...");
            programLocale = Locale.getDefault();
        }
        LangStrings.setLocale(programLocale);
        lg.debug(String.format("getLocale says: Display Language :<%s>, lang: <%s>",
                programLocale.getDisplayLanguage(), programLocale.getLanguage()));
        stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages", programLocale);
        if (stringsBundle.getLocale().equals(programLocale)) {
            lg.debug("language accepted..");
        } else {
            lg.debug("language fallback default...");
            programLocale = Locale.ENGLISH;
            Locale.setDefault(programLocale);
            stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages",
                    programLocale);
        }
        checkDatabaseDirectory();
    } catch (MissingResourceException ex) {
        lg.error("ERROR get resources <" + ex.getMessage() + "> try standart Strings...");
        System.err.println("ERROR get resources <" + ex.getMessage() + "> try standart Strings...");
        try {
            lg.debug("try get  default english locale from system...");
            programLocale = Locale.ENGLISH;
            Locale.setDefault(programLocale);
            stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages_en");
        } catch (Exception ex1) {
            lg.error("ERROR get resources <" + ex1.getMessage() + "> give up...");
            System.exit(-1);
        }
    } catch (NoDatabaseException ex) {
        showErrorDialog(ex.getLocalizedMessage());
        System.exit(-1);
    }
    //
    // jetzt die wichtigen anderen Sachen, die dauern.
    //
    prepareDatabase();
    currentConfig.setLogger(lg);
    btComm = new BTCommunication(databaseUtil);
    btComm.addActionListener(this);
    try {
        initializeGUI();
    } catch (SQLException ex) {
        lg.error("SQL ERROR <" + ex.getMessage() + "> give up...");
        System.err.println("ERROR while create GUI: <" + ex.getLocalizedMessage() + ">");
        ex.printStackTrace();
        System.exit(-1);
    } catch (ClassNotFoundException ex) {
        lg.error("CLASS NOT FOUND EXCEPTION <" + ex.getMessage() + "> give up...");
        System.err.println("ERROR while create GUI: <" + ex.getLocalizedMessage() + ">");
        ex.printStackTrace();
        System.exit(-1);
    }
    // Listener setzen (braucht auch die Maps)
    setGlobalChangeListener();
    //
    initLanuageMenu(programLocale);
    if (!SpxPcloggerProgramConfig.developDebug) {
        configPanel.setAllConfigPanlelsEnabled(false);
        logListPanel.setAllLogPanelsEnabled(false);
        setElementsConnected(false);
    }
    if (setLanguageStrings() < 1) {
        lg.error("setLanguageStrings() faild. give up...");
        System.exit(-1);
    }
    connectionPanel.setVirtDevicesBoxEnabled(false);
    startVirtualPortFinder(null);
    waitForMessage = 0;
}

From source file:edu.ku.brc.af.prefs.PrefsToolbar.java

/**
 * Loads a Section or grouping of Prefs.
 * @param sectionElement the section elemnent
 * @param altName the localized title//w  w  w  .  j a  v  a2 s. c o m
 */
protected void loadSectionPrefs(final Element sectionElement, final ResourceBundle resBundle) {
    RolloverCommand.setVertGap(2);

    //List<NavBoxButton> btns = new Vector<NavBoxButton>();
    //int totalWidth = 0;
    try {
        List<?> prefs = sectionElement.selectNodes("pref"); //$NON-NLS-1$
        //numPrefs = prefs.size();
        for (Iterator<?> iterPrefs = prefs.iterator(); iterPrefs.hasNext();) {
            org.dom4j.Element pref = (org.dom4j.Element) iterPrefs.next();

            String prefName = pref.attributeValue("name"); //$NON-NLS-1$
            String prefTitle = pref.attributeValue("title"); //$NON-NLS-1$
            String iconPath = pref.attributeValue("icon"); //$NON-NLS-1$
            String panelClass = pref.attributeValue("panelClass"); //$NON-NLS-1$
            String viewSetName = pref.attributeValue("viewsetname"); //$NON-NLS-1$
            String viewName = pref.attributeValue("viewname"); //$NON-NLS-1$
            String hContext = pref.attributeValue("help"); //$NON-NLS-1$

            if (AppContextMgr.isSecurityOn()) {
                PermissionSettings perm = SecurityMgr.getInstance().getPermission("Prefs." + prefName);
                //PermissionSettings.dumpPermissions("Prefs: "+prefName, perm.getOptions());
                if (!perm.canView()) // this means Enabled
                {
                    continue;
                }
            }

            if (StringUtils.isNotEmpty(prefTitle) && StringUtils.isNotEmpty(iconPath)
                    && StringUtils.isNotEmpty(panelClass)) {
                if (resBundle != null) {
                    try {
                        prefTitle = resBundle.getString(prefTitle);

                    } catch (MissingResourceException ex) {
                        log.error("Couldn't find key[" + prefTitle + "]");
                        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PrefsToolbar.class, ex);
                    }
                }

                ImageIcon icon;
                if (iconPath.startsWith("http") || iconPath.startsWith("file")) //$NON-NLS-1$ //$NON-NLS-2$
                {
                    icon = new ImageIcon(new URL(iconPath));
                } else {
                    icon = IconManager.getImage(iconPath);
                }

                if (icon != null) {
                    if (icon.getIconWidth() > iconSize || icon.getIconHeight() > iconSize) {
                        icon = new ImageIcon(
                                icon.getImage().getScaledInstance(iconSize, iconSize, Image.SCALE_SMOOTH));
                    }
                }
                if (icon == null) {
                    log.error("Icon was created - path[" + iconPath + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                }

                NavBoxButton btn = new NavBoxButton(getResourceString(prefTitle), icon);
                btn.setOpaque(false);
                btn.setVerticalLayout(true);
                btn.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 4));

                try {
                    Class<?> panelClassObj = Class.forName(panelClass);
                    Component comp = (Component) panelClassObj.newInstance();

                    if (comp instanceof PrefsPanelIFace) {
                        PrefsPanelIFace prefPanel = (PrefsPanelIFace) comp;
                        prefPanel.setName(prefName);
                        prefPanel.setTitle(prefTitle);
                        prefPanel.setHelpContext(hContext);

                        if (!prefPanel.isOKToLoad()
                                || (AppContextMgr.isSecurityOn() && !prefPanel.getPermissions().canView())) {
                            continue;
                        }
                        prefPanel.setPrefsPanelMgr(prefsPanelMgr);
                    }

                    if (panelClassObj == GenericPrefsPanel.class) {
                        if (StringUtils.isNotEmpty(viewSetName) && StringUtils.isNotEmpty(viewName)) {
                            GenericPrefsPanel genericPrefsPanel = (GenericPrefsPanel) comp;
                            genericPrefsPanel.createForm(viewSetName, viewName);

                        } else {
                            log.error(
                                    "ViewSetName[" + viewSetName + "] or ViewName[" + viewName + "] is empty!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        }
                    }

                    prefsPanelMgr.addPanel(prefTitle, comp);

                    add(btn.getUIComponent());

                } catch (Exception ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PrefsToolbar.class, ex);
                    log.error(ex); // XXX FIXME
                    ex.printStackTrace();
                }
                btn.addActionListener(new ShowAction(prefTitle, btn));
            }
        }

        if (getComponentCount() > 0) {
            prevBtn = (RolloverCommand) getComponent(0);
            prevBtn.setActive(true);
        }

        /*int aveWidth = totalWidth / btns.size();
        for (NavBoxButton nbb : btns)
        {
        Dimension size = nbb.getPreferredSize();
        if (size.width < aveWidth)
        {
            size.width = aveWidth;
        }
        nbb.setPreferredSize(size);
        nbb.setSize(size);
        } */

    } catch (Exception ex) {
        ex.printStackTrace();
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PrefsToolbar.class, ex);

        throw new RuntimeException(ex);
    } finally {
        RolloverCommand.setVertGap(0);
    }
}

From source file:org.cap.selfService.myAccount.ui.bean.AddressBookBackingBean.java

public String validatePartyFax() {

    String status = "sucess";
    FacesMessage message = new FacesMessage();
    FacesContext context = FacesContext.getCurrentInstance();
    Pattern p1 = Pattern.compile(expr1);
    Pattern p2 = Pattern.compile(expr2);

    Matcher m1 = p1.matcher((String) getFaxPartyIpTx().getValue());
    Matcher m2 = p2.matcher((String) getFaxPartyIpTx().getValue());

    try {/*from  w w w  . ja va  2  s.  c  om*/
        if (getCountryPartySelOneCho() != null && (getCountryPartySelOneCho().getValue().equals("US")
                || getCountryPartySelOneCho().getValue().equals("CA"))) {
            if (!m1.find() && !m2.find()) {
                message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(getFaxPartyIpTx().getClientId(context), message);
                status = "failure";
            }
        }

    } catch (MissingResourceException e) {
        sLog.debug(e.getMessage(), e);
        e.printStackTrace();
    }
    return status;
}