⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminbean.java

📁 实现了SyncML无线同步协议
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		try {            n = dbUserManager.countUsers(clause);		} catch (PersistentStoreException e) {            String msg = "Error counting users: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "countUsers", e);            throw new ServerException(msg, e);		}        return n;    }    /**     * Read a list of device that satisfy the specific conditions.     *     * @param clauses the conditions foe search informations.     *     * @return array of device     *     * @throws ServerException     * @throws AdminException     */    public Sync4jDevice[] getDevices(Clause clauses)    throws ServerException, AdminException {        log.fine("AdminBean method getDevices");        Sync4jDevice[] devices = null;		try {            devices = (Sync4jDevice[])ps.read(new Sync4jDevice(), clauses);		} catch (PersistentStoreException e) {            String msg = "Error reading devices: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "getDevices", e);            throw new ServerException(msg, e);		}		return devices;	}    /**     * Insert a new device.     *     * @param d the new device     *     * @return the device id     *     * @throws ServerException     * @throws AdminException     */    public String insertDevice(Sync4jDevice d)    throws ServerException, AdminException {        log.fine("AdminBean method insertDevice");		try {			ps.store(d);		} catch (PersistentStoreException e) {            String msg = "Error adding device: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "insertDevice", e);            throw new ServerException(msg, e);		}        return d.getDeviceId();	}    /**     * Update the information of specific device.     *     * @param d the device to update     *     * @throws ServerException     * @throws AdminException     */    public void setDevice(Sync4jDevice d)    throws ServerException, AdminException {        log.fine("AdminBean method setDevice");		try {			ps.store(d);		} catch (PersistentStoreException e) {            String msg = "Error updating device: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "setDevice", e);            throw new ServerException(msg, e);		}	}    /**     * Delete the specific device.     *     * @param deviceId the device id that identifies the device     *     * @throws ServerException     * @throws AdminException     */    public void deleteDevice(String deviceId)    throws ServerException, AdminException{        log.fine("AdminBean method deleteDevice");		try {            Sync4jDevice sd = new Sync4jDevice(deviceId, null, null);            ps.delete(sd);		} catch (PersistentStoreException e) {            String msg = "Error deleting device: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "deleteDevice", e);            throw new ServerException(msg, e);		}    }    /**     * Count the number of device that satisfy the specific clauses.     *     * @param clauses the specific conditions for search device     *     * @return the number of device finds     *     * @throws ServerException     * @throws AdminException     */    public int countDevices(Clause clauses)    throws ServerException, AdminException {        log.fine("AdminBean method countDevices");        int n = 0;		try {            String[] obj = (String[])ps.read(SEARCH_COUNT_DEVICES, clauses);            n = Integer.parseInt(obj[0]);		} catch (PersistentStoreException e) {            String msg = "Error counting devices: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "countDevices", e);            throw new ServerException(msg, e);		}		return n;	}    /**     * Read all principal that satisfy the clauses.     *     * @param clauses the specific conditions for search principal     *     * @return array of principal     *     * @throws ServerException     * @throws AdminException     */    public Sync4jPrincipal[] getPrincipals(Clause clauses)    throws ServerException, AdminException {        log.fine("AdminBean method getPrincipals");        Sync4jPrincipal[] principals = null;		try {			principals = (Sync4jPrincipal[])ps.read(new Sync4jPrincipal(null,null,null), clauses);		} catch (PersistentStoreException e) {            String msg = "Error reading principals: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "getPrincipals", e);            throw new ServerException(msg, e);		}		return principals;	}    /**     * Insert a new principal.     *     * @param p the new principal     *     * @return the principal id     *     * @throws ServerException     * @throws AdminException     */    public String insertPrincipal(Sync4jPrincipal p)    throws ServerException, AdminException {        log.fine("AdminBean method insertPrincipal");		try {			ps.store(p);		} catch (PersistentStoreException e) {            String msg = "Error adding rincipal: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "insertPrincipal", e);            throw new ServerException(msg, e);		}        return p.getId();	}    /**     * Delete the specific principal.     *     * @param principalId the principal id that identifies the principal     *     * @throws ServerException     * @throws AdminException     */    public void deletePrincipal(String principalId)    throws ServerException, AdminException {        log.fine("AdminBean method deletePrincipal");		try {            Sync4jPrincipal sp = new Sync4jPrincipal(principalId, null, null);            ps.delete(sp);		} catch (PersistentStoreException e) {            String msg = "Error deleting principal: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "deletePrincipal", e);            throw new ServerException(msg, e);		}	}    /**     * Count the number of principal that satisfy the specific clauses.     *     * @param clauses the specific conditions for search principal     *     * @return the number of principal finds     *     * @throws ServerException     * @throws AdminException     */    public int countPrincipals(Clause clauses)    throws ServerException, AdminException {        log.fine("AdminBean method countPrincipals");        int n = 0;		try {            String[] obj = (String[])ps.read(SEARCH_COUNT_PRINCIPALS, clauses);            n = Integer.parseInt(obj[0]);		} catch (PersistentStoreException e) {            String msg = "Error counting principals: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "countPrincipals", e);            throw new ServerException(msg, e);		}		return n;	}    /**     * Read all modules information     *     * @return an array with the modules information (empty if no objects are found)     *     * @throws ServerException     * @throws AdminException     */    public Sync4jModule[] getModulesName()    throws ServerException, AdminException {        log.fine("AdminBean method getModulesName");        Sync4jModule[] module = null;		try {			module = (Sync4jModule[])ps.read(Sync4jModule.class);		} catch (PersistentStoreException e) {            String msg = "Error reading modules: " + e.getMessage();			if (log.isLoggable(Level.SEVERE)) {				log.severe(msg);			}			log.throwing(getClass().getName(), "getPrincipals", e);            throw new ServerException(msg, e);		}        return module;    }    /**     * Read the information of the specific module     *     * @param moduleId the module id that identifies the module to search     *     * @return the relative information to the module     *     * @throws ServerException     * @throws AdminException     */    public Sync4jModule getModule(String moduleId)    throws ServerException, AdminException {        log.fine("AdminBean method getModule");        Sync4jModule module = null;        Sync4jConnector[] sc0 = null;        Sync4jSourceType[] sst0 = null; Sync4jSourceType[] sst1 = null;        SyncSource[] ss0 = null;		try {            module = new Sync4jModule(moduleId, null, null);            ps.read(module);            //for each SyncConnector read the SyncSourceType and            //for each SyncSourceType read the SyncSource            Sync4jConnector[] syncConnectors = module.getConnectors();            for (int i=0; (syncConnectors != null) && i<syncConnectors.length; i++) {                Sync4jConnector sc = syncConnectors[i];                Sync4jSourceType[] syncSourceTypes = sc.getSourceTypes();                for (int y=0; (syncSourceTypes != null) && y<syncSourceTypes.length; y++) {                    Sync4jSource[] sync4jSources = (Sync4jSource[])ps.read(syncSourceTypes[y], null);                    ArrayList syncSources = new ArrayList();                    ArrayList syncSourcesFailed = new ArrayList();                    for (int z=0; z<sync4jSources.length; z++) {                        try {                            SyncSource syncSource = (SyncSource)BeanFactory.getNoInitBeanInstance(                                                 config.getClassLoader(),                                                 sync4jSources[z].getConfig()                                           );                            syncSources.add(syncSource);                        } catch (BeanException e) {                            Throwable t = e.getCause();                            String msg = "Error creating SyncSource "                                       + module.getModuleName()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -