From 0ed2c1124cf1b9e49a2ec1fa0126a8df09f9e758 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 7 Oct 2014 09:18:11 +0200 Subject: Repackage to org.cristalise --- .../java/com/c2kernel/process/module/Module.java | 223 --------------------- .../com/c2kernel/process/module/ModuleConfig.java | 42 ---- .../c2kernel/process/module/ModuleException.java | 29 --- .../com/c2kernel/process/module/ModuleImport.java | 86 -------- .../com/c2kernel/process/module/ModuleImports.java | 77 ------- .../com/c2kernel/process/module/ModuleInfo.java | 34 ---- .../com/c2kernel/process/module/ModuleManager.java | 210 ------------------- .../c2kernel/process/module/ModuleResource.java | 79 -------- .../com/c2kernel/process/module/ModuleScript.java | 53 ----- 9 files changed, 833 deletions(-) delete mode 100644 src/main/java/com/c2kernel/process/module/Module.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleConfig.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleException.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleImport.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleImports.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleInfo.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleManager.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleResource.java delete mode 100644 src/main/java/com/c2kernel/process/module/ModuleScript.java (limited to 'src/main/java/com/c2kernel/process/module') diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java deleted file mode 100644 index a1a11c7..0000000 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import java.util.ArrayList; -import java.util.Properties; - -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.imports.ImportAgent; -import com.c2kernel.entity.imports.ImportDependency; -import com.c2kernel.entity.imports.ImportDependencyMember; -import com.c2kernel.entity.imports.ImportItem; -import com.c2kernel.entity.imports.ImportOutcome; -import com.c2kernel.entity.imports.ImportRole; -import com.c2kernel.entity.proxy.AgentProxy; -import com.c2kernel.entity.proxy.ItemProxy; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.RolePath; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.Property; -import com.c2kernel.scripting.ErrorInfo; -import com.c2kernel.scripting.ScriptingEngineException; -import com.c2kernel.utils.Logger; - -public class Module extends ImportItem { - - private ModuleInfo info; - private String resURL; - private ModuleImports imports = new ModuleImports(); - private ArrayList config = new ArrayList(); - private ArrayList scripts = new ArrayList(); - - public Module() { - super(); - // Module properties - properties.add(new Property("Type", "Module", false)); - setInitialPath("/desc/modules/"); - setWorkflow("NoWorkflow"); - setWorkflowVer(0); - imports.list.add(this); - } - - public void runScript(String event, AgentProxy user, boolean isServer) throws ScriptingEngineException { - for (ModuleScript script : scripts) { - if (script.shouldRun(event, isServer)) { - Logger.msg("Running "+script.event+" "+script.target+" script from "+name); - Object result = script.getScript(ns, user).execute(); - if (result instanceof ErrorInfo) { - ErrorInfo error = (ErrorInfo) result; - Logger.error(error.toString()); - if (error.getFatal()) - throw new ScriptingEngineException("Fatal Script Error"); - } - else if (result != null) - Logger.msg(result.toString()); - } - } - } - - public void setModuleXML(String moduleXML) { - ImportOutcome moduleOutcome = new ImportOutcome("Module", 0, "last", null); - moduleOutcome.data = moduleXML; - outcomes.add(moduleOutcome); - } - - @Override - public void setNamespace(String ns) { - super.setNamespace(ns); - replaceProp(new Property("Namespace", ns, false)); - } - - @Override - public void setName(String name) { - super.setName(name); - replaceProp(new Property("Name", name, false)); - } - - private void replaceProp(Property newProp) { - for (Property prop : properties) { - if (prop.getName().equals("Namespace")) { - prop.setMutable(newProp.isMutable()); - prop.setValue(newProp.getValue()); - return; - } - } - properties.add(newProp); - } - public void importAll(ItemProxy serverEntity, AgentProxy systemAgent, String moduleXML, boolean reset) throws Exception { - setModuleXML(moduleXML); - - for (ModuleResource thisRes : imports.getResources()) { - try { - thisRes.setNamespace(ns); - thisRes.create(systemAgent.getPath(), reset); - } catch (Exception ex) { - Logger.error(ex); - Logger.die("Error importing module resources. Unsafe to continue."); - } - } - - for (ImportRole thisRole : imports.getRoles()) { - RolePath rolePath; - try { - String roleName = thisRole.name; - if (roleName.indexOf('/') > -1) roleName = roleName.substring(roleName.indexOf('/')+1); - rolePath = Gateway.getLookup().getRolePath(roleName); - if (rolePath.hasJobList() != thisRole.hasJobList()) { - Logger.msg("Module.importAll() - Role '"+thisRole.name+"' has incorrect joblist settings. Correcting."); - rolePath.setHasJobList(thisRole.hasJobList()); - Gateway.getLookupManager().createRole(rolePath); - } - } catch (ObjectNotFoundException ex) { - Logger.msg("Module.importAll() - Role '"+thisRole.name+"' not found. Creating."); - thisRole.create(systemAgent.getPath(), reset); - } - } - - for (ImportAgent thisAgent : imports.getAgents()) { - try { - Gateway.getLookup().getAgentPath(thisAgent.name); - Logger.msg(3, "Module.importAll() - User '"+thisAgent.name+"' found."); - continue; - } catch (ObjectNotFoundException ex) { } - Logger.msg("Module.importAll() - User '"+thisAgent.name+"' not found. Creating."); - thisAgent.create(systemAgent.getPath(), reset); - } - - for (ImportItem thisItem : imports.getItems()) { - thisItem.setNamespace(ns); - thisItem.create(systemAgent.getPath(), reset); - } - - } - - public Properties getProperties(boolean isServer) { - Properties props = new Properties(); - for (ModuleConfig thisProp : config) { - if (thisProp.include(isServer)) - props.put(thisProp.name, thisProp.value); - } - return props; - } - - public ArrayList getScripts() { - return scripts; - } - - public void setResURL(String resURL) { - this.resURL = resURL; - } - public String getDesc() { - return info.desc; - } - public String getVersion() { - return info.version; - } - public String getResURL() { - return resURL; - } - public ArrayList getDependencies() { - return info.dependency; - } - public boolean hasDependency(String dep) { - return info.dependency.contains(dep); - } - - public ModuleInfo getInfo() { - return info; - } - - public void setInfo(ModuleInfo info) { - this.info = info; - replaceProp(new Property("Version", info.version, true)); - } - - public ModuleImports getImports() { - return imports; - } - - public void setImports(ModuleImports imp) { - // Add dependency for all children - imports = imp; - ImportDependency children = new ImportDependency("Contents"); - for (ModuleImport thisImport : imports.list) { - DomainPath path = thisImport.domainPath; - if (path != null) - children.dependencyMemberList.add(new ImportDependencyMember(path.toString())); - } - dependencyList.add(children); - } - - public void setConfig(ArrayList config) { - this.config = config; - } - - public void setScripts(ArrayList scripts) { - this.scripts = scripts; - } - - public ArrayList getConfig() { - return config; - } - - -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleConfig.java b/src/main/java/com/c2kernel/process/module/ModuleConfig.java deleted file mode 100644 index 2cc2453..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -public class ModuleConfig { - - public String name; - public String value; - public String target; - - public ModuleConfig() { - } - - public ModuleConfig(String name, String value, String target) { - super(); - this.name = name; - this.value = value; - this.target = target; - } - - public boolean include(boolean isServer) { - return (target == null || target.length() == 0 || isServer == target.equals("server")); - } -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleException.java b/src/main/java/com/c2kernel/process/module/ModuleException.java deleted file mode 100644 index 8eaa511..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleException.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -public class ModuleException extends Exception { - - public ModuleException(String msg) { - super(msg); - } - -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleImport.java b/src/main/java/com/c2kernel/process/module/ModuleImport.java deleted file mode 100644 index 327c55a..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleImport.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.InvalidItemPathException; -import com.c2kernel.lookup.ItemPath; - -public abstract class ModuleImport { - - protected String ns; - protected String name; - protected DomainPath domainPath; - protected ItemPath itemPath; - - public ModuleImport() { - } - - public abstract void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, - ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification; - - public void setID( String uuid ) throws InvalidItemPathException - { - if (uuid != null && uuid.length() > 0) itemPath = new ItemPath(uuid); - } - - public String getID() { - return itemPath==null?null:itemPath.getUUID().toString(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setNamespace(String ns) { - this.ns = ns; - } - - public String getNamespace() { - return ns; - } - - public DomainPath getDomainPath() { - return domainPath; - } - - public void setDomainPath(DomainPath domainPath) { - this.domainPath = domainPath; - } - - public ItemPath getItemPath() { - return itemPath; - } - - public void setItemPath(ItemPath itemPath) { - this.itemPath = itemPath; - } -} \ No newline at end of file diff --git a/src/main/java/com/c2kernel/process/module/ModuleImports.java b/src/main/java/com/c2kernel/process/module/ModuleImports.java deleted file mode 100644 index 3cc2ee1..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleImports.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import java.util.ArrayList; - -import com.c2kernel.entity.imports.ImportAgent; -import com.c2kernel.entity.imports.ImportItem; -import com.c2kernel.entity.imports.ImportRole; -import com.c2kernel.utils.CastorArrayList; - -public class ModuleImports extends CastorArrayList { - - public ModuleImports() - { - super(); - } - - public ModuleImports(ArrayList aList) - { - super(aList); - } - - public ArrayList getResources() { - ArrayList subset = new ArrayList(); - for (ModuleImport imp : list) { - if (imp instanceof ModuleResource) - subset.add((ModuleResource)imp); - } - return subset; - } - - public ArrayList getItems() { - ArrayList subset = new ArrayList(); - for (ModuleImport imp : list) { - if (imp instanceof ImportItem) - subset.add((ImportItem)imp); - } - return subset; - } - - public ArrayList getAgents() { - ArrayList subset = new ArrayList(); - for (ModuleImport imp : list) { - if (imp instanceof ImportAgent) - subset.add((ImportAgent)imp); - } - return subset; - } - - public ArrayList getRoles() { - ArrayList subset = new ArrayList(); - for (ModuleImport imp : list) { - if (imp instanceof ImportRole) - subset.add((ImportRole)imp); - } - return subset; - } -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleInfo.java b/src/main/java/com/c2kernel/process/module/ModuleInfo.java deleted file mode 100644 index 2f29fd1..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleInfo.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import java.util.ArrayList; - -public class ModuleInfo { - - public String desc; - public String version; - public ArrayList dependency = new ArrayList(); - - public ModuleInfo() { - } - -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleManager.java b/src/main/java/com/c2kernel/process/module/ModuleManager.java deleted file mode 100644 index 8153033..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleManager.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Properties; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.proxy.AgentProxy; -import com.c2kernel.entity.proxy.ItemProxy; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.persistency.outcome.OutcomeValidator; -import com.c2kernel.persistency.outcome.Schema; -import com.c2kernel.process.Gateway; -import com.c2kernel.scripting.ScriptingEngineException; -import com.c2kernel.utils.FileStringUtility; -import com.c2kernel.utils.Logger; - -public class ModuleManager { - ArrayList modules = new ArrayList(); - HashMap modulesXML = new HashMap(); - Properties props = new Properties(); - AgentProxy user; - boolean isServer; - OutcomeValidator moduleValidator; - - public ModuleManager(Enumeration moduleEnum, boolean isServer) throws ModuleException { - this.isServer = isServer; - try { - Schema moduleSchema = new Schema("Module", 0, - FileStringUtility.url2String(Gateway.getResource().getKernelResourceURL("boot/OD/Module.xsd"))); - moduleValidator = new OutcomeValidator(moduleSchema); - } catch (InvalidDataException ex) { - Logger.error(ex); - throw new ModuleException("Module Schema is not valid"); - } catch (IOException ex) { - throw new ModuleException("Could not load Module Schema from kernel resources"); - } - ArrayList loadedModules = new ArrayList(); - ArrayList moduleNs = new ArrayList(); - while(moduleEnum.hasMoreElements()) { - URL newModuleURL = moduleEnum.nextElement(); - try { - String moduleXML = FileStringUtility.url2String(newModuleURL); - String errors = moduleValidator.validate(moduleXML); - if (errors.length() > 0) - throw new ModuleException("Module XML found at "+newModuleURL+" was not valid: "+errors); - Module newModule = (Module)Gateway.getMarshaller().unmarshall(moduleXML); - if (newModule.getResURL() != null && newModule.getResURL().length()>0) Gateway.getResource().addModuleBaseURL(newModule.getNamespace(), newModule.getResURL()); - modules.add(newModule); - modulesXML.put(newModule.getNamespace(), moduleXML); - if (loadedModules.contains(newModule.getName())) throw new ModuleException("Module name clash: "+newModule.getName()); - if (moduleNs.contains(newModule.getNamespace())) throw new ModuleException("Module namespace clash: "+newModule.getNamespace()); - Logger.debug(4, "Module found: "+newModule.getNamespace()+" - "+newModule.getName()); - loadedModules.add(newModule.getName()); moduleNs.add(newModule.getNamespace()); - } catch (ModuleException e) { - Logger.error("Could not load module description from "+newModuleURL); - throw e; - } catch (Exception e) { - Logger.error(e); - throw new ModuleException("Could not load module.xml from "+newModuleURL); - } - } - - Logger.debug(5, "Checking dependencies"); - boolean allDepsPresent = true; - - ArrayList prevModules = new ArrayList(); - for (int i=0; i deps = thisMod.getDependencies(); - depClean = true; - for (String dep : deps) { - Logger.msg(6, thisMod.getName()+" depends on "+dep); - if (!loadedModules.contains(dep)) { - Logger.error("UNMET MODULE DEPENDENCY: "+thisMod.getName()+" requires "+dep); - allDepsPresent = false; - } - else if (!prevModules.contains(dep)) { - Logger.msg(1, "ModuleManager: Shuffling "+thisMod.getName()+" to the end to fulfil dependency on "+dep); - modules.remove(i); - modules.add(thisMod); - thisMod = modules.get(i); - skipped++; - depClean = false; - break; - } - } - if (skipped > modules.size()-i) { - StringBuffer badMod = new StringBuffer(); - for (Module mod : modules.subList(i, modules.size())) { - badMod.append(mod.getName()).append(" "); - } - Logger.die("Circular module dependencies involving: "+badMod); - } - } - // Current module is 'next', this is the correct order to load the properties - Properties modProp = thisMod.getProperties(isServer); - for (Enumeration e = modProp.propertyNames(); e.hasMoreElements();) { - String propName = (String)e.nextElement(); - props.put(propName, modProp.get(propName)); - } - prevModules.add(thisMod.getName()); - } - if (!allDepsPresent) Logger.die("Unmet module dependencies. Cannot continue"); - } - - public void setUser(AgentProxy user) { - this.user = user; - } - - public String getModuleVersions() { - StringBuffer ver = new StringBuffer(); - for (Module thisMod : modules) { - if (ver.length()>0) ver.append("; "); - ver.append(thisMod.getName()+" ("+thisMod.getVersion()+")"); - } - return ver.toString(); - } - - - public Properties getAllModuleProperties() { - return props; - } - - public void runScripts(String event) { - for (Module thisMod : modules) { - try { - thisMod.runScript(event, user, isServer); - } catch (ScriptingEngineException e) { - Logger.error(e); - Logger.die(e.getMessage()); - } - } - } - - public void registerModules() throws ModuleException { - ItemProxy serverEntity; - try { - serverEntity = Gateway.getProxyManager().getProxy(new DomainPath("/servers/"+Gateway.getProperties().getString("ItemServer.name"))); - } catch (ObjectNotFoundException e) { - throw new ModuleException("Cannot find local server name."); - } - Logger.debug(3, "Registering modules"); - - boolean reset = Gateway.getProperties().getBoolean("Module.reset", false); - - for (Module thisMod : modules) { - - Logger.msg("Registering module "+thisMod.getName()); - try { - String thisResetKey = "Module."+thisMod.getNamespace()+".reset"; - boolean thisReset = reset; - if (Gateway.getProperties().containsKey(thisResetKey)) - thisReset = Gateway.getProperties().getBoolean(thisResetKey); - thisMod.importAll(serverEntity, user, modulesXML.get(thisMod.getNamespace()), thisReset); - } catch (Exception e) { - Logger.error(e); - throw new ModuleException("Error importing items for module "+thisMod.getName()); - } - Logger.msg("Module "+thisMod.getName()+" registered"); - - try { - thisMod.runScript("startup", user, true); - } catch (ScriptingEngineException e) { - Logger.error(e); - throw new ModuleException("Error in startup script for module "+thisMod.getName()); - } - - } - } - - public void dumpModules() { - for (Module thisMod : modules) { - try { - FileStringUtility.string2File(thisMod.getName()+".xml", Gateway.getMarshaller().marshall(thisMod)); - } catch (Exception e) { - Logger.error(e); - } - } - - } -} diff --git a/src/main/java/com/c2kernel/process/module/ModuleResource.java b/src/main/java/com/c2kernel/process/module/ModuleResource.java deleted file mode 100644 index da40403..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleResource.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.process.Bootstrap; -import com.c2kernel.utils.Logger; - -public class ModuleResource extends ModuleImport { - - public int version; - public String resourceType; - public String resourceLocation; - - public ModuleResource() { - // if not given, version defaults to 0 - version = 0; - } - - @Override - public void create(AgentPath agentPath, boolean reset) - throws ObjectNotFoundException, ObjectCannotBeUpdated, - CannotManageException, ObjectAlreadyExistsException { - try { - domainPath = Bootstrap.verifyResource(ns, name, version, resourceType, itemPath, resourceLocation, reset); - } catch (Exception e) { - Logger.error(e); - throw new CannotManageException("Exception verifying module resource "+ns+"/"+name); - } - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getResourceLocation() { - return resourceLocation; - } - - public void setResourceLocation(String resourceLocation) { - this.resourceLocation = resourceLocation; - } - - -} \ No newline at end of file diff --git a/src/main/java/com/c2kernel/process/module/ModuleScript.java b/src/main/java/com/c2kernel/process/module/ModuleScript.java deleted file mode 100644 index 2d50510..0000000 --- a/src/main/java/com/c2kernel/process/module/ModuleScript.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.process.module; - -import com.c2kernel.entity.proxy.AgentProxy; -import com.c2kernel.scripting.Script; -import com.c2kernel.scripting.ScriptingEngineException; - -public class ModuleScript { - - - public String target; - public String event; - public String lang; - public String script; - public ModuleScript() { - } - - public ModuleScript(String target, String event, String lang, String script) { - super(); - this.target = target; - this.event = event; - this.lang = lang; - this.script = script; - } - - public Script getScript(String ns, AgentProxy user) throws ScriptingEngineException { - return new Script(lang, ns+" "+target+" "+event, script, user); - } - - public boolean shouldRun(String event, boolean isServer) { - return ((this.target == null || this.target.length() == 0 || isServer == target.equals("server")) && - (this.event == null || this.event.length() == 0 || event.equals(this.event))); - } -} -- cgit v1.2.3