Search in sources :

Example 1 with ErrorVisitor

use of org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor in project cxf by apache.

the class JavaToWSContainer method checkParams.

public void checkParams(ErrorVisitor errs) throws ToolException {
    super.checkParams(errs);
    CommandDocument doc = super.getCommandDocument();
    if (doc.hasParameter(ToolConstants.CFG_FRONTEND)) {
        String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
        if (!ToolConstants.JAXWS_FRONTEND.equals(ft) && !ToolConstants.SIMPLE_FRONTEND.equals(ft)) {
            Message msg = new Message("INVALID_FRONTEND", LOG, new Object[] { ft });
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
        if (ToolConstants.SIMPLE_FRONTEND.equals(ft) && doc.getParameter(ToolConstants.CFG_DATABINDING) != null && !ToolConstants.AEGIS_DATABINDING.equals(doc.getParameter(ToolConstants.CFG_DATABINDING))) {
            Message msg = new Message("INVALID_DATABINDING_FOR_SIMPLE", LOG);
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
    }
    if (doc.hasParameter(ToolConstants.CFG_WRAPPERBEAN)) {
        String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
        if (ft != null && !ToolConstants.JAXWS_FRONTEND.equals(ft)) {
            Message msg = new Message("WRAPPERBEAN_WITHOUT_JAXWS", LOG);
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
    }
    if (errs.getErrors().size() > 0) {
        Message msg = new Message("PARAMETER_MISSING", LOG);
        throw new ToolException(msg, new BadUsageException(getUsage(), errs));
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument) ToolException(org.apache.cxf.tools.common.ToolException) ErrorVisitor(org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor)

Example 2 with ErrorVisitor

use of org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor in project cxf by apache.

the class IDLToWSDL method checkParams.

public void checkParams(ErrorVisitor errors) throws ToolException {
    CommandDocument doc = super.getCommandDocument();
    if (!doc.hasParameter(ToolCorbaConstants.CFG_IDLFILE)) {
        errors.add(new ErrorVisitor.UserError("IDL file has to be specified"));
    }
    if ((doc.hasParameter(ToolCorbaConstants.CFG_SCHEMA)) && (doc.hasParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA))) {
        errors.add(new ErrorVisitor.UserError("Options -n & -T cannot be used together"));
    }
    if ((doc.hasParameter(ToolCorbaConstants.CFG_MODULETONS)) && ((doc.hasParameter(ToolCorbaConstants.CFG_LOGICAL)) || (doc.hasParameter(ToolCorbaConstants.CFG_PHYSICAL)) || (doc.hasParameter(ToolCorbaConstants.CFG_SCHEMA)) || (doc.hasParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA)))) {
        errors.add(new ErrorVisitor.UserError("Options -mns and -L|-P|-T|-n cannot be use together"));
    }
    if (doc.hasParameter(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE)) {
        String sequenceOctetType = doc.getParameter(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE);
        if (sequenceOctetType != null && (!(sequenceOctetType.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY) || sequenceOctetType.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY)))) {
            errors.add(new ErrorVisitor.UserError("Invalid value specified for -s option"));
        }
    }
    if (doc.hasParameter(ToolCorbaConstants.CFG_ADDRESSFILE)) {
        String addressFileName = doc.getParameter(ToolCorbaConstants.CFG_ADDRESSFILE);
        File addressFile = new File(addressFileName);
        if (!addressFile.canRead() || !addressFile.isFile()) {
            errors.add(new ErrorVisitor.UserError("Invalid value specified for -f option\n" + "\"" + addressFileName + "\" cannot be read"));
        }
    }
    if (errors.getErrors().size() > 0) {
        Message msg = new Message("PARAMETER_MISSING", LOG);
        throw new ToolException(msg, new BadUsageException(getUsage(), errors));
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument) ToolException(org.apache.cxf.tools.common.ToolException) ErrorVisitor(org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor) File(java.io.File)

Aggregations

Message (org.apache.cxf.common.i18n.Message)2 ToolException (org.apache.cxf.tools.common.ToolException)2 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)2 CommandDocument (org.apache.cxf.tools.common.toolspec.parser.CommandDocument)2 ErrorVisitor (org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor)2 File (java.io.File)1