summaryrefslogtreecommitdiff
path: root/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java124
1 files changed, 20 insertions, 104 deletions
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java
index 6d281686..1cdeda94 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java
@@ -16,143 +16,59 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import at.buergerkarte.namespaces.cardchannel.CommandAPDUType;
-import at.buergerkarte.namespaces.cardchannel.ResetType;
-import at.buergerkarte.namespaces.cardchannel.ScriptType;
-import at.buergerkarte.namespaces.cardchannel.VerifyAPDUType;
-import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType;
import at.gv.egiz.bku.slcommands.InfoboxUpdateCommand;
import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
public class InfoboxUpdateCommandImpl extends
- SLCommandImpl<InfoboxUpdateRequestType> implements InfoboxUpdateCommand {
+ AbstractInfoboxCommandImpl<InfoboxUpdateRequestType> implements InfoboxUpdateCommand {
private static Log log = LogFactory.getLog(InfoboxUpdateCommandImpl.class);
- public static final String INFOBOX_IDENTIFIER_CARD_CHANNEL = "CardChannel";
+ @Override
+ public String getName() {
+ return "InfoboxUpdateRequest";
+ }
- protected String infoboxIdentifier;
-
- protected List<Object> cardChannelScript;
-
@Override
- public String getInfoboxIdentifier() {
- return infoboxIdentifier;
+ protected String getInfoboxIdentifier(InfoboxUpdateRequestType request) {
+ return request.getInfoboxIdentifier();
}
-
+
@Override
- public void init(SLCommandContext ctx, Object request)
- throws SLCommandException {
+ public void init(SLCommandContext ctx, Object request) throws SLCommandException {
super.init(ctx, request);
InfoboxUpdateRequestType req = getRequestValue();
- infoboxIdentifier = req.getInfoboxIdentifier();
+ if (req.getAssocArrayParameters() != null &&
+ !(infobox instanceof AssocArrayInfobox)) {
+ log.info("Got AssocArrayParameters but Infobox type is not AssocArray.");
+ throw new SLCommandException(4010);
+ }
- if (INFOBOX_IDENTIFIER_CARD_CHANNEL.equals(infoboxIdentifier)) {
-
- if (req.getAssocArrayParameters() != null) {
- log.info("Got AssocArrayParameters but Infobox type is BinaryFile.");
- throw new SLCommandException(4010);
- }
-
- Base64XMLContentType binaryFileParameters = req.getBinaryFileParameters();
- if (binaryFileParameters == null) {
- log.info("Got no BinaryFileParameters but Infobox type is BinaryFile.");
- throw new SLCommandException(4010);
- }
-
- if (binaryFileParameters.getBase64Content() == null) {
- log.info("Got Base64Content but ContentIsXMLEntity is true.");
- throw new SLCommandException(4010);
- }
-
- List<Object> content = binaryFileParameters.getXMLContent().getContent();
- if (content.isEmpty()) {
- log.info("Got no XMLContent but ContentIsXMLEntity is true.");
- throw new SLCommandException(4010);
- }
-
- for (Object element : content) {
- if (!(element instanceof ScriptType)) {
- log.info("Infobox identifier is '" + infoboxIdentifier + "' but XMLContent does not contain 'Script'.");
- throw new SLCommandException(4010);
- }
-
- setCardChannelScript(((ScriptType) element).getResetOrCommandAPDUOrVerifyAPDU());
- }
-
- if (getCardChannelScript() == null) {
- log.info("Infobox identifier is '" + infoboxIdentifier + "' but XMLContent does not contain 'Script'.");
- throw new SLCommandException(4010);
- }
-
- } else {
- throw new SLCommandException(4002,
- SLExceptionMessages.EC4002_INFOBOX_UNKNOWN,
- new Object[] { infoboxIdentifier });
+ if (req.getBinaryFileParameters() != null &&
+ !(infobox instanceof BinaryFileInfobox)) {
+ log.info("Got BinaryFileParameters but Infobox type is not BinaryFile.");
+ throw new SLCommandException(4010);
}
}
- public List<Object> getCardChannelScript() {
- return cardChannelScript;
- }
-
- public void setCardChannelScript(List<Object> cardChannelScript) {
- this.cardChannelScript = cardChannelScript;
- }
-
@Override
public SLResult execute() {
try {
- if (INFOBOX_IDENTIFIER_CARD_CHANNEL.equals(getInfoboxIdentifier())) {
-
- executeCardChannelScript();
- return new InfoboxUpdateResultImpl();
-
- } else {
- throw new SLCommandException(4002,
- SLExceptionMessages.EC4002_INFOBOX_UNKNOWN,
- new Object[] { infoboxIdentifier });
- }
+ return infobox.update(getRequestValue(), getCmdCtx());
} catch (SLCommandException e) {
- return new ErrorResultImpl(e, cmdCtx.getLocale());
+ return new ErrorResultImpl(e, getCmdCtx().getLocale());
}
}
-
- protected void executeCardChannelScript() throws SLCommandException {
-
- if (cardChannelScript != null) {
-
- for (Object element : cardChannelScript) {
- if (element instanceof ResetType) {
-
- } else if (element instanceof CommandAPDUType) {
-
- } else if (element instanceof VerifyAPDUType) {
-
- }
- }
-
- }
-
- }
-
- @Override
- public String getName() {
- return "InfoboxUpdateRequest";
- }
}