enqueue processors only on web packets

This commit is contained in:
Peter Hormanns 2013-04-24 17:30:20 +02:00
parent 2fc3ba4741
commit 51f563d208
4 changed files with 33 additions and 7 deletions

View File

@ -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

View File

@ -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();

View File

@ -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";
}
}

View File

@ -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 <T extends AbstractEntity> 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 <T extends AbstractEntity> 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 <T extends AbstractEntity> 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();
}
}