From 51f563d2080d147dfa404464339d48a396bd888a Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 24 Apr 2013 17:30:20 +0200 Subject: [PATCH] enqueue processors only on web packets --- hsarback/database/data.sql | 2 +- .../hsadmin/core/model/AbstractModuleImpl.java | 4 ++++ .../de/hsadmin/core/qserv/NullProcessor.java | 18 ++++++++++++++++++ .../hsadmin/mods/pac/PacProcessorFactory.java | 16 ++++++++++------ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 hsarback/src/de/hsadmin/core/qserv/NullProcessor.java diff --git a/hsarback/database/data.sql b/hsarback/database/data.sql index 6c3822b..ba76af5 100644 --- a/hsarback/database/data.sql +++ b/hsarback/database/data.sql @@ -6,7 +6,7 @@ INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_nu INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) VALUES ('SW/B', 'Static-Web/Base', 300, true, 200); INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) - VALUES ('WEB', 'Web/Base', 100, true, 300); + VALUES ('PAC', 'PAC/Web', 100, true, 300); -- -- Table: basecomponent diff --git a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java index 89f0d77..6162a4b 100644 --- a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java +++ b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java @@ -10,6 +10,7 @@ import javax.persistence.NonUniqueResultException; import javax.persistence.Query; import de.hsadmin.core.qserv.EntityProcessorFactory; +import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.mods.user.UnixUser; @@ -179,6 +180,9 @@ public abstract class AbstractModuleImpl implements ModuleInterface { } protected void queueProcessor(Processor proc, UnixUser user, AbstractEntity entity, String action) { + if (proc == null || proc instanceof NullProcessor) { + return; + } Entity entityInfo = entity.getClass().getAnnotation(Entity.class); String entityTypeName = entityInfo != null ? entityInfo.name() : entity.getClass().getSimpleName(); StringBuilder details = new StringBuilder(); diff --git a/hsarback/src/de/hsadmin/core/qserv/NullProcessor.java b/hsarback/src/de/hsadmin/core/qserv/NullProcessor.java new file mode 100644 index 0000000..6d42f2f --- /dev/null +++ b/hsarback/src/de/hsadmin/core/qserv/NullProcessor.java @@ -0,0 +1,18 @@ +package de.hsadmin.core.qserv; + + +public class NullProcessor extends AbstractProcessor { + + private static final long serialVersionUID = 1L; + + @Override + public Object process() throws ProcessorException { + return "nil"; + } + + @Override + public String logInfo() { + return "NullProcessor\n"; + } + +} diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index e84311d..60c5889 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -8,6 +8,7 @@ import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.qserv.CompoundProcessor; import de.hsadmin.core.qserv.CreateFileProcessor; import de.hsadmin.core.qserv.EntityProcessorFactory; +import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.ProcessorException; import de.hsadmin.core.qserv.ShellProcessor; @@ -23,7 +24,8 @@ public class PacProcessorFactory implements EntityProcessorFactory { public Processor createCreateProcessor( EntityManager em, T entity) throws ProcessorException { Pac pac = (Pac) entity; - if (pac.getBasepac().getName().startsWith("PAC/")) { + String basepacName = pac.getBasepac().getName(); + if (basepacName.startsWith("PAC") || basepacName.startsWith("DW") || basepacName.startsWith("SW")) { String pacName = pac.getName(); Hive hive = pac.getHive(); UnixUser unixUser = getPacAdminUser(pac); @@ -41,7 +43,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { createHttpdVirtualProc(hive), createAccountingRulesProc()); } else { - return new ShellProcessor("exit 0"); //TODO: Nothing should happen here. + return new NullProcessor(); } } @@ -76,17 +78,19 @@ public class PacProcessorFactory implements EntityProcessorFactory { public Processor createUpdateProcessor(EntityManager em, T entity) throws ProcessorException { Pac pac = (Pac) entity; - if (pac.getBasepac().getName().startsWith("PAC/")) { + String basepacName = pac.getBasepac().getName(); + if (basepacName.startsWith("PAC") || basepacName.startsWith("DW") || basepacName.startsWith("SW")) { return createSetQuotaProc(pac); } else { - return new ShellProcessor("exit 0"); //TODO: Nothing should happen here. + return new NullProcessor(); } } @Override public Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException { Pac pac = (Pac) entity; - if (pac.getBasepac().getName().startsWith("PAC/")) { + String basepacName = pac.getBasepac().getName(); + if (basepacName.startsWith("PAC") || basepacName.startsWith("DW") || basepacName.startsWith("SW")) { Hive hive = pac.getHive(); WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName())); waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor( @@ -99,7 +103,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { createAccountingRulesProc()), "remove packet"); return waiting; } else { - return new ShellProcessor("exit 0"); //TODO: Nothing should happen here. + return new NullProcessor(); } }