Java 类javax.ejb.FinderException 实例源码

项目:libreacs    文件:ScriptJsfBean.java   
/** Creates a new instance of ScriptJsfBean */
public ScriptJsfBean() {
    String name = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("scriptname");
    if (name != null) {
        this.name = name;
        try {
            ScriptLocal s = Ejb.lookupScriptBean().findByPrimaryKey(name);
            description = s.getDescription();
            text = new String(s.getScript());
        } catch (FinderException ex) {
            //Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


}
项目:libreacs    文件:DeviceProfileBean.java   
public String load() {
    try {
        DeviceProfileLocal d = Ejb.lookupDeviceProfileBean().findByPrimaryKey(name);
        setPeriodicInformInterval(d.getInforminterval());
        setDaysToKeepStats(d.getDayskeepstats());
        setSaveParamValuesInterval(d.getSaveParamValuesInterval());
        saveParamValuesOnBoot = d.getSaveParamValuesOnBoot();
        saveParamValuesOnChange = d.getSaveParamValuesOnChange();
        saveLog = d.getSaveLog();
        saveParamValues = d.getSaveParamValues();
        scriptName = d.getScriptname();

        props = new ProfilePropertySet(name);
        props.Load();
        return "loaded";
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
    }
    return null;
}
项目:libreacs    文件:DeviceProfileBean.java   
public Collection getFwVersions() {
//        javax.faces.context.FacesContext.getCurrentInstance().
        //System.out.println("DeviceProfileBean.getFwVersions hwid=" + hwid);
        ArrayList<SelectItem> a = new ArrayList<SelectItem>();
        a.add(new SelectItem(DeviceProfile2SoftwareLocal.NOUPDATE, "No update"));
        a.add(new SelectItem(DeviceProfile2SoftwareLocal.AUTOUPDATE, "Automatic"));
        try {
//            Iterator cfgs = Ejb.lookupConfigurationBean().findAll().iterator();
            Iterator<SoftwareLocal> fws = Ejb.lookupSoftwareBean().findByHardware(hwid).iterator();
            while (fws.hasNext()) {
                SoftwareLocal fw = fws.next();
                a.add(new SelectItem(fw.getVersion(), fw.getVersion()));
            }
        } catch (FinderException ex) {
        }
        return a;
    }
项目:libreacs    文件:ServiceBean.java   
public String load() {
    try {
        ServiceLocal svc = Ejb.lookupServiceBean().findByPrimaryKey(id);
        name = svc.getName();
        description = svc.getDescription();
        type = svc.getType();
        props = new ServicePropertySet(id);
        props.Load();
        if (type == null || type.equals("") || type.equals(TYPE_GENERIC)) {
            System.out.println("ServiceBean::load return \"loaded_service\"");
            return "loaded_service";
        }

        System.out.println("ServiceBean::load return \"loaded_" + type + "\"");
        return "loaded_" + type;
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
    }

    return null;
}
项目:libreacs    文件:ProfilePropertySet.java   
@Override
public void Load() {
    //System.out.println ("ProfilePropertySet::Load name="+profilename);
    ProfilePropertyLocalHome pplh = Ejb.lookupProfilePropertyBean();
    Collection<ProfilePropertyLocal> props;
    try {
        props = pplh.findByProfile(profilename);
        for (ProfilePropertyLocal p : props) {
            //System.out.println ("ProfilePropertySet::Load "+p.getName()+"->"+p.getValue());
            original.put(p.getName(), new Property(p.getName(), p.getValue()));
        }
        super.Load();
    } catch (FinderException ex) {
        //System.out.println ("ProfilePropertySet::Load ex="+ex.getMessage());
    }
}
项目:libreacs    文件:Script.java   
public static Object call(Context cx, Scriptable thisObj, Object[] args, Function funObj) {
    if (args.length < 1) {
        ((Script) thisObj).log(Level.WARNING, "call function with zero args");
        return null;
    }
    ScriptLocal script;
    try {
        script = Ejb.lookupScriptBean((String) args[0]);
        /*
        Object [] newargs = null;
        if (args.length > 1) {
        newargs = new Object[args.length - 1];
        System.arraycopy(args, 1, newargs, 0, args.length - 1);
        Scriptable a = cx.newArray(thisObj, newargs);
        thisObj.put("arguments", thisObj, newargs);
        }
         */
        return cx.evaluateString(thisObj, new String(script.getScript()), (String) args[0], 1, null);
    } catch (FinderException ex) {
        ((Script) thisObj).log(Level.SEVERE, "CALL: function " + args[0] + " not found.");
    }
    return null;
}
项目:libreacs    文件:Application.java   
private void createDefaultProfile() {
    DeviceProfileLocal def;
    try {
        def = Ejb.lookupDeviceProfileBean().findByPrimaryKey("Default");
        if (def.getSaveParamValuesOnBoot() == null) {
            def.setSavestats(true);
            def.setSaveParamValuesOnChange(true);
            def.setSaveParamValuesOnBoot(true);
            def.setSaveParamValuesInterval(7);
        }
    } catch (FinderException ex) {
        try {
            def = Ejb.lookupDeviceProfileBean().create("Default");
            def.setDayskeepstats(7);
            def.setInforminterval(1800);
            def.setSavestats(true);
            def.setSaveParamValuesOnChange(true);
            def.setSaveParamValuesOnBoot(true);
            def.setSaveParamValuesInterval(7);
        } catch (CreateException ex1) {
            Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex1);
        }
    }
}
项目:libreacs    文件:ConfigJsfBean.java   
public String Save() {
//        System.out.println ("Config.Save: hwid="+hwid+" name="+name);
        try {
            ConfigurationLocal s = Ejb.lookupConfigurationBean().findByPrimaryKey(new ConfigurationPK(hwid, name));
            HardwareModelLocal hw = s.getHardware();
            Vendor v = Vendor.getVendor(hw.getOui(), hw.getHclass(), hw.getVersion());

            String[] r = v.CheckConfig(filename, name, version, config);
            if (r != null && r.length > 0) {
                setErrorMessage(r);
            }
            s.setFilename(filename);
            s.setVersion(version);
            s.setConfig(config.getBytes());
            setSaved();
        } catch (FinderException ex) {
            setErrorMessage(ex.getMessage());
        }
        return "cfgsaved";
    }
项目:libreacs    文件:HostsBean.java   
public String connectionRequest() {
        if (crw == null || crw.getState() == State.TERMINATED) {
            try {
                System.out.println("Connection request START");
                HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
//            crw = new ConnectionRequestWorker(url, conreqUser, conreqPass);
                crw = new ConnectionRequestWorker(h);
                setLastcrres("In progress");
                crw.start();
            } catch (FinderException ex) {
                System.out.println("FinderException: " + ex.getLocalizedMessage());
                setLastcrres(ex.getLocalizedMessage());
                Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            System.out.println("Connection request no......");
        }
        return null;
    }
项目:libreacs    文件:HostsBean.java   
public Collection getConfigs() {
        try {
//            Iterator cfgs = Ejb.lookupConfigurationBean().findAll().iterator();
            Iterator cfgs = Ejb.lookupConfigurationBean().findByHwid(hwid).iterator();
            ArrayList<SelectItem> a = new ArrayList<SelectItem>();
            a.add(new SelectItem(CONFIG_NONE));
            while (cfgs.hasNext()) {
                ConfigurationLocal cfg = (ConfigurationLocal) cfgs.next();
                a.add(new SelectItem(cfg.getName()));
            }
            return a;
        } catch (FinderException ex) {
            ex.printStackTrace();
        }
        return null;
    }
项目:libreacs    文件:HostsBean.java   
public Collection getHardwareList() {
    try {
        Iterator cfgs = Ejb.lookupHardwareModelBean().findAll().iterator();
        ArrayList<SelectItem> a = new ArrayList<SelectItem>();
        while (cfgs.hasNext()) {
            HardwareModelLocal model = (HardwareModelLocal) cfgs.next();
            a.add(new SelectItem(((Integer) model.getId()).toString(), model.getDisplayName()));
            if (hwid == null) {
                hwid = (Integer) model.getId();
            }
        }
        return a;
    } catch (FinderException ex) {
        ex.printStackTrace();
    }
    return null;
}
项目:libreacs    文件:HostsBean.java   
protected String getServiceForm() {
    ServiceLocal service;
    try {
        service = Ejb.lookupServiceBean().findByPrimaryKey(svcidin);
    } catch (FinderException ex) {
        Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    String formname = service.getType() + "_assign.xhtml";
    try {
        InputStream rs = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(formname);
        if (rs != null) {
            return service.getType();
        }
    } catch (Exception e) {
    }
    return null;
}
项目:libreacs    文件:HostsBean.java   
public Collection autocompleteSerialNo(Object v) {
    //System.out.println ("CPE autocompleteSerialNo");
    ArrayList<String> a = new ArrayList<String>(COUNT_SUGGESTIONS);
    Iterator it;
    try {
        //System.out.println ("AUTOCOMPLETE hwid="+hwid+" v="+v);
        it = Ejb.lookupHostsBean().findByPartialSN(hwid, (String) v).iterator();
    } catch (FinderException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
    for (int i = 0; i < COUNT_SUGGESTIONS && it.hasNext(); i++) {
        a.add(i, ((HostsLocal) it.next()).getSerialno());
    }
    return a;
}
项目:libreacs    文件:HostsBean.java   
private DataModelNode getCfg() {
        if (thecfg == null) {
            parameterNames = null;
            parameterValues = null;
            currentPath = "";
            thecfg = new DataModelNode(null);
            InputStream in;
            try {
                //in = new FileInputStream("c:/temp/tr.txt");
                BackupLocalHome blh = Ejb.lookupBackupBean();
                Timestamp t = blh.getTimeOfLastBackup(id);

                BackupLocal bl = blh.findByPrimaryKey(new BackupPK(id, t, BackupLocal.TYPE_VENDOR_INDEPENDANT));
                in = new ByteArrayInputStream(bl.getCfg());
                thecfg.load(in);
                setPath(currentPath = thecfg.getName());
            } /*catch (FileNotFoundException ex) {
            Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
            }*/ catch (FinderException ex) {
                setErrorMessage("No saved values found. \nCheck settings in profile or wait for device contacting ACS.");
//                Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return thecfg;
    }
项目:libreacs    文件:HostsBean.java   
private Hashtable<String, String> getAtmErrorStats(Hashtable<String, String> m, int type) {
    if (m == null) {
        HostsLocal h;
        try {
            h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
            ATMErrorsStatsLocal s = Ejb.lookupATMErrorsStatsBean().findByPrimaryKey(new ATMErrorsStatsPK((Integer) h.getId(), h.getLastcontact(), type));
            m = ejb2map(s);
            m.remove("hostid");
            m.remove("time");
            m.remove("type");
        } catch (FinderException ex) {
            m = new Hashtable<String, String>();
        }

    }
    return m;
}
项目:libreacs    文件:HwModelJsfBean.java   
public String Save() {
//        System.out.println("ScriptJsfBean.Save () id=" + id);
        try {
            HardwareModelLocal s = Ejb.lookupHardwareModelBean().findByPrimaryKey(id);
            s.setDisplayName(displayName);
            s.setHclass(hclass);
            s.setManufacturer(manufacturer);
            s.setOui(oui);
            s.setVersion(version);
        } catch (FinderException ex) {
            setErrorMessage(ex.getMessage());
            return null;
        }
        setSaved();
        return "hwsaved";
    }
项目:libreacs    文件:Configurator.java   
private boolean getProfileProps(Properties p, String root, String profile, Hashtable<String, Boolean> profiles) throws FinderException {
    if (profiles.containsKey(profile)) {
        return false;
    }
    profiles.put(profile, true);
    DeviceProfileLocal prf = Ejb.lookupDeviceProfileBean().findByPrimaryKey(profile);
    String baseprofile = prf.getBaseprofile();
    if (baseprofile != null && !baseprofile.equals("")) {
        boolean r = getProfileProps(p, root, baseprofile, profiles);
        if (!r) {
            return false;
        }
    }

    String profilename = prf.getName();
    Iterator<ProfilePropertyLocal> profileprops = Ejb.lookupProfilePropertyBean().findByProfile(profile).iterator();// prf.getProperties().iterator();
    while (profileprops.hasNext()) {
        ProfilePropertyLocal profileprop = profileprops.next();
        String name = profileprop.getName();
        String value = profileprop.getValue();
        log(Level.INFO, "Set property: source is profile '" + profilename + "' " + name + " -> " + value);
        putNormalizedProperty(p, root, name, value);
        //p.setProperty(name, value);
    }
    return true;
}
项目:libreacs    文件:ScriptJsfBean.java   
public Object[] getAll() throws FinderException {
//        System.out.println ("ScriptJsfBean.getAll");
        if (arrayScriptNames != null) {
            return arrayScriptNames;
        } else {
            return arrayScriptNames = Ejb.lookupScriptBean().findAll().toArray();
        }
    }
项目:libreacs    文件:SoftwaresBean.java   
public Object[] getAll() throws FinderException {
    if (arraySw != null) {
        return arraySw;
    } else {
        return arraySw = Ejb.lookupSoftwareBean().findAll().toArray();
    }
}
项目:libreacs    文件:DeviceProfileBean.java   
public String save() {
    try {
        save(Ejb.lookupDeviceProfileBean().findByPrimaryKey(name));
        setSaved();
        return "saved";
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
    }
    return null;
}
项目:libreacs    文件:DeviceProfileBean.java   
public Collection getList() {
    try {
        Iterator lst = Ejb.lookupDeviceProfileBean().findAll().iterator();
        ArrayList<SelectItem> a = new ArrayList<SelectItem>();
        while (lst.hasNext()) {
            DeviceProfileLocal it = (DeviceProfileLocal) lst.next();
            a.add(new SelectItem(it.getName(), it.getName()));
        }
        return a;
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
    }
    return null;
}
项目:libreacs    文件:DeviceProfileBean.java   
public Collection getDevices() {
        //System.out.println("DeviceProfileBean.getDevices");
        try {
//            Iterator cfgs = Ejb.lookupConfigurationBean().findAll().iterator();
            Iterator<HardwareModelLocal> hwms = Ejb.lookupHardwareModelBean().findAll().iterator();
            ArrayList<SelectItem> a = new ArrayList<SelectItem>();
            while (hwms.hasNext()) {
                HardwareModelLocal hwm = hwms.next();
                a.add(new SelectItem(hwm.getId(), hwm.getDisplayName()));
            }
            return a;
        } catch (FinderException ex) {
        }
        return null;
    }
项目:libreacs    文件:DeviceProfileBean.java   
public Collection getScriptNames() {
    ArrayList<SelectItem> a = new ArrayList<SelectItem>();
    try {
        Iterator<ScriptLocal> fws = Ejb.lookupScriptBean().findAll().iterator();
        while (fws.hasNext()) {
            ScriptLocal script = fws.next();
            a.add(new SelectItem(script.getName(), script.getName()));
        }
    } catch (FinderException ex) {
    }
    return a;
}
项目:libreacs    文件:DeviceProfileBean.java   
public Collection getFwMap() {
    ArrayList<FirmwareMapEntry> a = new ArrayList<FirmwareMapEntry>();
    Map<Integer, HardwareModelLocal> hwmap = Ejb.getHardwareModelMap();

    try {
        Iterator<DeviceProfile2SoftwareLocal> i = Ejb.lookupDeviceProfile2SoftwareBean().findByProfile(name).iterator();
        while (i.hasNext()) {
            DeviceProfile2SoftwareLocal o = i.next();
            HardwareModelLocal hwm = hwmap.get(o.getHwid());
            a.add(new FirmwareMapEntry(hwm.getDisplayName(), (Integer) hwm.getId(), o.getVersion()));
        }
    } catch (FinderException ex) {
    }
    return a;
}
项目:libreacs    文件:HardwareModelsBean.java   
public Object[] getAll() throws FinderException {
    if (models != null) {
        return models;
    } else {
        return models = Ejb.lookupHardwareModelBean().findAll().toArray();
    }
}
项目:libreacs    文件:ConfigsBean.java   
public Object[] getAll() throws FinderException {
    if (arrayCfgs != null) {
        //System.out.println("CONFIGS: getAll (cached)");
        return arrayCfgs;
    } else {
        //System.out.println("CONFIGS: getAll");
        return arrayCfgs = Ejb.lookupConfigurationBean().findAll().toArray();
    }
}
项目:libreacs    文件:ServiceBean.java   
public Collection getAll() {
    try {
        return Ejb.lookupServiceBean().findAll();
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
        return null;
    }
}
项目:libreacs    文件:Application.java   
private void setProperty(String name, String value) throws CreateException {
    PropertyLocalHome plh = Ejb.lookupPropertyBean();
    PropertyLocal pl = null;
    try {
        pl = plh.findByPrimaryKey(new PropertyPK(0, PropertyLocal.TYPE_APPLICATION, name));
        pl.setValue(value);
    } catch (FinderException ex) {
        plh.create(0, PropertyLocal.TYPE_APPLICATION, name, value);
    }
}
项目:libreacs    文件:ServiceBean.java   
private Collection getServices(String type) {
    try {
        Iterator<ServiceLocal> svcs = Ejb.lookupServiceBean().findByType(type).iterator();
        ArrayList<SelectItem> a = new ArrayList<SelectItem>();
        while (svcs.hasNext()) {
            ServiceLocal svc = svcs.next();
            a.add(new SelectItem(svc.getId(), svc.getName()));
        }
        return a;
    } catch (FinderException ex) {
        ex.printStackTrace();
    }
    return null;
}
项目:libreacs    文件:ServicePropertySet.java   
@Override
public void Load() {
    Collection<ServicePropertyLocal> props;
    try {
        props = Ejb.lookupServicePropertyBean().findByServiceId(Serviceid);
        for (ServicePropertyLocal p : props) {
            original.put(p.getName(), new ServiceProperty(p.getName(), p.getValue(), p.getIsparam()));
        }
        super.Load();
    } catch (FinderException ex) {
        Logger.getLogger(ServicePropertySet.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:libreacs    文件:ScriptsBean.java   
public Object[] getAll() throws FinderException {
    if (arrayScriptNames != null) {
        return arrayScriptNames;
    } else {
        return arrayScriptNames = Ejb.lookupScriptBean().findAll().toArray();
    }
}
项目:libreacs    文件:Configurator.java   
private void runScript(String scriptName, TransferComplete tc) {

        try {
            ScriptLocal sb;
            sb = Ejb.lookupScriptBean(scriptName);
            Script script = new Script(lastInform, new String(sb.getScript()), host, tc, this, sessionid);
            script.run();
        } catch (FinderException ex) {
            log(Level.WARNING, "Configuration script '" + scriptName + "' not found in db.");
        }
    }
项目:libreacs    文件:HostsBean.java   
public String requestReboot() {
    try {
        HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
        h.setReboot(true);
        connectionRequest();
    } catch (FinderException ex) {
    }
    return null;
}
项目:libreacs    文件:HostsBean.java   
protected void LoadProperties() {
    try {
        HostsLocal h = Ejb.lookupHostsBean().findByPrimaryKey(id);
        LoadProperties(h);
    } catch (FinderException ex) {
        setErrorMessage(ex.getMessage());
    }
}
项目:libreacs    文件:HostsBean.java   
public String getItem() {
    //System.out.println ("getItem");
    HostsLocal h;
    try {
        h = Ejb.lookupHostsBean().findByPrimaryKey(id);
        findResult = new ArrayList<HostsLocal>();
        findResult.add(h);
        loadItem(h);
    } catch (FinderException ex) {
        Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return "cpegetitem";
}
项目:libreacs    文件:HostsBean.java   
public String findStats() {
        Timestamp tf = new Timestamp(timeFrom.getTime());
        Timestamp tt = new Timestamp(timeTo.getTime());
        try {
//            System.out.println ("DSLstats: hwid="+hwid+" sn="+sn+" tf="+tf+" tt="+tt);
            HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
            DSLStatsLocalHome s = Ejb.lookupDSLStatsBean();
            dslstatslist = s.findByCpeAndTime2((Integer) h.getId(), tf, tt);
        } catch (FinderException ex) {
            setErrorMessage(ex.getMessage());
        }
        return null;
    }
项目:libreacs    文件:SoftwareJsfBean.java   
public String load() {
//        System.out.println("Software.load hwid=" + hwid);
        try {
            SoftwareLocal s = Ejb.lookupSoftwareBean().findByPrimaryKey(new SoftwarePK(this.hwid, version));
            this.filename = s.getFilename();
            HardwareModelLocal hw = Ejb.lookupHardwareModelBean().findByPrimaryKey(this.hwid);
            hwmodel = hw.getDisplayName();
        } catch (FinderException ex) {
            setErrorMessage(ex.getMessage());
        }
        return "swloaded";
    }
项目:libreacs    文件:SoftwareJsfBean.java   
public Collection getAll() {
//        System.out.println("SoftwareJsfBean.getAll hwid=" + hwid);
//        if (hwid == null || hwid == 0) hwid = 10;
        try {
            if (hwid == null || hwid == 0) {
                return Collections.EMPTY_LIST;
//              return Ejb.lookupSoftwareBean().findAll();
            }
            return Ejb.lookupSoftwareBean().findByHardware(hwid);
        } catch (FinderException ex) {
            //setErrorMessage(ex.getMessage());
        }
        return Collections.EMPTY_LIST;
    }
项目:libreacs    文件:SoftwareJsfBean.java   
private DataModelNode getCfg() {
//        System.out.println("SoftwareJsfBean.getCfg currentPath=" + currentPath + " thecfg=" + thecfg);
        if (thecfg == null) {
            parameterNames = null;
            parameterValues = null;
//            currentPath = "";
            if (hwid == null || hwid == 0) {
                return null;
            }

            thecfg = new DataModelNode(null);
            InputStream in;
            try {
                //in = new FileInputStream("c:/temp/tr.txt");
                SoftwareDetailLocalHome sdlh = Ejb.lookupSoftwareDetailBean();
                SoftwareDetailLocal sdl = sdlh.findByPrimaryKey(new SoftwareDetailPK(hwid, version));
                in = new ByteArrayInputStream(sdl.getParamNames());
                thecfg.load(in, true);
                if (currentPath == null || currentPath.equals("")) {
                    currentPath = thecfg.getName();
                }
                setPath2(currentPath);

            } /*catch (FileNotFoundException ex) {
            Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
            }*/ catch (FinderException ex) {
                thecfg = null;
                //setErrorMessage("No saved values found. \nCheck settings in profile or wait for device contacting ACS.");
//                Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return thecfg;
    }
项目:libreacs    文件:HwModelJsfBean.java   
public Object[] getAll() throws FinderException {
//        System.out.println("HwModelJsfBean.getAll");
        if (arrayAll != null) {
            return arrayAll;
        } else {
            return arrayAll = Ejb.lookupHardwareModelBean().findAll().toArray();
        }
    }