当前位置: 首页>>代码示例>>Java>>正文


Java ValidationException类代码示例

本文整理汇总了Java中javax.xml.bind.ValidationException的典型用法代码示例。如果您正苦于以下问题:Java ValidationException类的具体用法?Java ValidationException怎么用?Java ValidationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValidationException类属于javax.xml.bind包,在下文中一共展示了ValidationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: post

import javax.xml.bind.ValidationException; //导入依赖的package包/类
@PostMapping("/")
@ResponseBody
ResponseEntity<StreamingResponseBody> post(@RequestPart final MultipartFile file)
        throws Exception {

    if (file.isEmpty()) {
        throw new ValidationException("file was empty");
    }

    final HttpHeaders headers = new HttpHeaders();
    headers.setContentDispositionFormData("filename", "sample.txt");

    final StreamingResponseBody body = out -> out.write(file.getBytes());

    return ResponseEntity.ok()
            .headers(headers)
            .contentType(MediaType.valueOf("application/force-download"))
            .body(body);
}
 
开发者ID:backpaper0,项目名称:spring-boot-sandbox,代码行数:20,代码来源:DemoApplication.java

示例2: insertEventDuty

import javax.xml.bind.ValidationException; //导入依赖的package包/类
@FXML
@Override
public void insertEventDuty() throws ValidationException {
    if(validate()) {
        EventDutyDTO eventDutyDTO = new EventDutyDTO();
        eventDutyDTO.setName(name.getText());
        eventDutyDTO.setDescription(description.getText());
        eventDutyDTO.setStartTime(DateHelper.mergeDateAndTime(date.getValue(), startTime.getValue()));
        eventDutyDTO.setEndTime(endTime.getValue() == null ? DateHelper.mergeDateAndTime(date.getValue(), startTime.getValue().plusHours(2)) : DateHelper.mergeDateAndTime(date.getValue(), endTime.getValue()));
        eventDutyDTO.setEventType(EventType.NonMusicalEvent);
        eventDutyDTO.setEventStatus(EventStatus.Unpublished);
        eventDutyDTO.setLocation(eventLocation.getText());
        eventDutyDTO.setPoints((points.getText() == null || points.getText().isEmpty()) ? null : Double.valueOf(points.getText()));

        eventDutyDTO = EventScheduleManager.createEventDuty(eventDutyDTO);
        EventScheduleController.addEventDutyToGUI(eventDutyDTO); // add event to agenda
        EventScheduleController.setDisplayedLocalDateTime(eventDutyDTO.getStartTime().toLocalDateTime()); // set agenda view to week of created event
        EventScheduleController.resetSideContent(); // remove content of sidebar
        EventScheduleController.setSelectedAppointment(eventDutyDTO); // select created appointment
    }
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:22,代码来源:CreateNonMusicalEventController.java

示例3: save

import javax.xml.bind.ValidationException; //导入依赖的package包/类
@FXML
@Override
protected void save() throws ValidationException {
    if(validate()) {
        Agenda.Appointment selectedAppointment = EventScheduleController.getSelectedAppointment();
        EventDutyDTO oldEventDutyDTO = EventScheduleController.getEventForAppointment(selectedAppointment);
        EventScheduleController.removeSelectedAppointmentFromCalendar(selectedAppointment);

        EventDutyDTO eventDutyDTO = new EventDutyDTO();
        eventDutyDTO.setEventDutyId(oldEventDutyDTO.getEventDutyId());
        eventDutyDTO.setName(name.getText());
        eventDutyDTO.setDescription(description.getText());
        eventDutyDTO.setStartTime(DateHelper.mergeDateAndTime(date.getValue(), startTime.getValue()));
        eventDutyDTO.setEndTime(DateHelper.mergeDateAndTime(date.getValue(), endTime.getValue()));
        eventDutyDTO.setEventType(EventType.NonMusicalEvent);
        eventDutyDTO.setEventStatus(EventStatus.Unpublished);
        eventDutyDTO.setLocation(eventLocation.getText());
        eventDutyDTO.setPoints(((points.getText() == null || points.getText().isEmpty()) ? null : Double.valueOf(points.getText())));

        EventScheduleManager.updateEventDuty(eventDutyDTO, initEventDutyDTO);
        EventScheduleController.addEventDutyToGUI(eventDutyDTO);
        EventScheduleController.setDisplayedLocalDateTime(eventDutyDTO.getStartTime().toLocalDateTime()); // set agenda view to week of created event
        EventScheduleController.resetSideContent(); // remove content of sidebar
    }
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:26,代码来源:EditNonMusicalEventController.java

示例4: validate

import javax.xml.bind.ValidationException; //导入依赖的package包/类
public void validate() throws ValidationException {
    Validator.validateMandatoryString(name, 255);
    Validator.validateString(description, 255);
    Validator.validateMandatoryTimestamp(startTime);
    Validator.validateTimestampAfterToday(startTime);
    Validator.validateMandatoryTimestamp(endTime);
    Validator.validateTimestampAfterToday(endTime);
    Validator.validateTimestamp1BeforeTimestamp2(startTime, endTime);
    if(eventType == null || !EventType.contains(eventType.toString())) {
        throw new ValidationException("Eventtype wrong");
    }
    if(eventStatus == null || !EventStatus.contains(eventStatus.toString())) {
        throw new ValidationException("Eventstatus wrong");
    }
    Validator.validateString(conductor, 25);
    Validator.validateString(location, 255);
    Validator.validateDouble(defaultPoints, 0, Double.MAX_VALUE);
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:19,代码来源:EventDutyModel.java

示例5: createEventDuty

import javax.xml.bind.ValidationException; //导入依赖的package包/类
public static EventDutyDTO createEventDuty(EventDutyDTO eventDutyDTO) throws ValidationException {
    EventDutyModel eventDutyModel = createEventDutyModel(eventDutyDTO);
    eventDutyModel.validate();
    EventDutyEntity eventDutyEntity = createEventDutyEntity(eventDutyModel);

    eventDutyEntity = eventDutyEntityPersistanceFacade.put(eventDutyEntity);

    // create connection between event duty and musical work
    if(eventDutyDTO.getMusicalWorks() != null) {
        for(MusicalWorkDTO musicalWorkDTO : eventDutyDTO.getMusicalWorks()) {
            if(musicalWorkDTO != null) {
                createEventDutyMusicalWorks(eventDutyEntity, musicalWorkDTO);
            }
        }
    }

    HashMap<String, Integer> musicanCapacityMap = CalculateMusicianCapacity.checkCapacityInRange(eventDutyModel.getStartTime(), eventDutyModel.getEndTime());
    if(!musicanCapacityMap.isEmpty()) {
        MessageHelper.showWarningMusicianCapacityMessage(musicanCapacityMap, eventDutyDTO);
    }

    eventDutyDTO.setEventDutyId(eventDutyEntity.getEventDutyId());
    return eventDutyDTO;
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:25,代码来源:EventScheduleManager.java

示例6: convertJaxbException

import javax.xml.bind.ValidationException; //导入依赖的package包/类
/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occured
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:Jaxb2Marshaller.java

示例7: validateAttributes

import javax.xml.bind.ValidationException; //导入依赖的package包/类
private void validateAttributes(MateriaPrima mp) throws ValidationException {
	String returnMs = "";
	Integer quantidade = mp.getQuantidade();
	Integer codigo = mp.getCodigo();
	Double preco = mp.getPreco();
	if (mp.getNome() == null || mp.getNome().isEmpty()) {
		returnMs += "'Nome' ";
	}
	if (quantidade.toString() == null || quantidade.toString().isEmpty()) {
		returnMs += "'Quantidade' ";
	}
	if (mp.toString() == null || preco.toString().isEmpty()) {
		returnMs += "'Preco' ";
	}
	if (codigo.toString() == null || codigo.toString().isEmpty()) {
		returnMs += "'Codigo' ";
	}
	if (!returnMs.isEmpty()) {
		throw new ValidationException(
				String.format("Os argumento[%s] obrigatorios estao nulos ou com valores invalidos", returnMs));
	}
}
 
开发者ID:rafaaxits,项目名称:Panela-Fit-Oficial,代码行数:23,代码来源:MateriaPrimaPaneController.java

示例8: validateAttributes

import javax.xml.bind.ValidationException; //导入依赖的package包/类
private void validateAttributes(Fornecedor fornecedor) throws ValidationException {
	String returnMs = "";
	Integer codigo = fornecedor.getCodigo();
	if (fornecedor.getNomeFornecedor() == null || fornecedor.getNomeFornecedor().isEmpty()) {
		returnMs += "'Nome' ";
	}
	if (fornecedor.getEnderecoFornecedor() == null || fornecedor.getEnderecoFornecedor().isEmpty()) {
		returnMs += "'Endereço' ";
	}
	if (fornecedor.getTelefone() == null || fornecedor.getTelefone().isEmpty()) {
		returnMs += "'Telefone' ";
	}
	if (codigo.toString() == null || codigo.toString().isEmpty()) {
		returnMs += "'Codigo' ";
	}
	if (!returnMs.isEmpty()) {
		throw new ValidationException(
				String.format("Os argumento[%s] obrigatorios estao nulos ou com valores invalidos", returnMs));
	}
}
 
开发者ID:rafaaxits,项目名称:Panela-Fit-Oficial,代码行数:21,代码来源:FornecedorPaneController.java

示例9: validateAttributes

import javax.xml.bind.ValidationException; //导入依赖的package包/类
private void validateAttributes(Venda venda) throws ValidationException {
	String returnMs = "";
	Integer codigo = venda.getCodigo();

	if (venda.getCliente() == null) {
		returnMs += "'Cliente' ";
	}
	if (venda.getFuncionario() == null) {
		returnMs += "'Funcionario '";
	}
	if (codigo.toString() == null) {
		returnMs += "'Codigo'";
	}
	if (venda.getListaItensDeVenda() == null) {
		returnMs += "'ListaItensDeVenda' ";
	}
	if (venda.getDataDaVenda() == null) {
		returnMs += "'DataVenda' ";
	}
	if (!returnMs.isEmpty()) {
		throw new ValidationException(
				String.format("Os arumentos[%s] obrigatorios estao nulos ou com valores invalidos", returnMs));
	}
}
 
开发者ID:rafaaxits,项目名称:Panela-Fit-Oficial,代码行数:25,代码来源:VendaPaneController.java

示例10: getDetail

import javax.xml.bind.ValidationException; //导入依赖的package包/类
/**
 * Attempt to get the most informative detail from the given exception
 * @param e Exception to dig
 * @return Detail String
 */
protected String getDetail(final Exception e) {
    
    if (e == null) return null;
    
    if (e instanceof ValidationException || e instanceof MarshalException) {
        
        Throwable t = e.getCause();
        
        if (t != null) {
            while (t.getCause() != null) {
                t = t.getCause();
            }
            return t.getMessage();
        }
    }
    
    if (e instanceof IllegalArgumentException) {
        return "Unable to parse XML: " + e.getMessage();
    }
    
    return e.getMessage();
}
 
开发者ID:laverca,项目名称:laverca,代码行数:28,代码来源:JaxbDeserializer.java

示例11: validateSource

import javax.xml.bind.ValidationException; //导入依赖的package包/类
public static List<String> validateSource(String source, String del) throws ValidationException
{
    List<String> results = null;
    String[] splittedElements = source.split(del);
    results = new ArrayList<String>();

    for(String element:splittedElements)
    {
        if(isValidCommand(element))
            results.add(element);
        else
            throw new ValidationException(String.format("{0} is not a valid command!",element));
    }
    return results;

}
 
开发者ID:floriandanielit,项目名称:iapi-automator,代码行数:17,代码来源:Validator.java

示例12: Interpreter

import javax.xml.bind.ValidationException; //导入依赖的package包/类
public Interpreter(String program){
    _commands = null;
    _logger = Logger.getLogger(Interpreter.class.getName());
    try
    {
        _commands = Validator.validateSource(program);
        set_creationFailed(false);
        _json = new ResultJSON();
        _resultJson = new Gson();
        _supportedInputs = new ArrayList<String>(Arrays.asList("text:","password:","reset:","image:","file:","checkbox:","radiobutton:","button:","image:","hidden:","submit"));
        _logger.log(Level.INFO,"creation successful");

    }
    catch (ValidationException ex)
    {
        _logger.log(Level.SEVERE, "Invalid source, check syntax");
        set_creationFailed(true);
    }

}
 
开发者ID:floriandanielit,项目名称:iapi-automator,代码行数:21,代码来源:Interpreter.java

示例13: addOrReplaceRequisition

import javax.xml.bind.ValidationException; //导入依赖的package包/类
/**
 * Updates or adds a complete requisition with foreign source "foreignSource"
 *
 * @param requisition a {@link org.opennms.netmgt.provision.persist.requisition.Requisition} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@POST
@Consumes(MediaType.APPLICATION_XML)
@Transactional
public Response addOrReplaceRequisition(final Requisition requisition) {
    try {
        requisition.validate();
    } catch (final ValidationException e) {
        LogUtils.debugf(this, e, "error validating incoming requisition with foreign source '%s'", requisition.getForeignSource());
        throw getException(Status.BAD_REQUEST, e.getMessage());
    }

    debug("addOrReplaceRequisition: Adding requisition %s (containing %d nodes)", requisition.getForeignSource(), requisition.getNodeCount());
    m_accessService.addOrReplaceRequisition(requisition);
    return Response.seeOther(getRedirectUri(m_uriInfo, requisition.getForeignSource())).build();

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:23,代码来源:RequisitionRestService.java

示例14: testTransformation

import javax.xml.bind.ValidationException; //导入依赖的package包/类
@Test
public void testTransformation() throws TransformerException {
    XslTransformer transformer = new XslTransformer(getTransformationFile());
    Document transformedXml = transformer.transform(getXmlInputFile());
    checkResult(transformedXml);

    XslTransformer transformer2 = new XslTransformer(getTransformationFile());
    Document transformedXml2 = transformer2.transform(getXmlInputFile());
    checkResult(transformedXml2);

    XslTransformer transformer3 = new XslTransformer(getTransformationFile());
    Document transformedXml3 = transformer3.transform(getXmlInputFile());
    checkResult(transformedXml3);

    File schemaFile = getTargetSchemaFile();
    if (schemaFile != null) {
        String xml = DomUtil.documentToString(transformedXml);
        try {
            new XsdValidator(schemaFile, getResourceResolver()).validate(xml);
        } catch (ValidationException e) {
            errorCollector.addError(e);
        }
    }
}
 
开发者ID:mnuessler,项目名称:cakupan-maven-plugin,代码行数:25,代码来源:XslTransformationTestCase.java

示例15: addOrReplaceRequisition

import javax.xml.bind.ValidationException; //导入依赖的package包/类
/**
 * Updates or adds a complete requisition with foreign source "foreignSource"
 *
 * @param requisition a {@link org.opennms.netmgt.provision.persist.requisition.Requisition} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@POST
@Consumes(MediaType.APPLICATION_XML)
@Transactional
public Response addOrReplaceRequisition(final Requisition requisition) {
    writeLock();
    try {
    	try {
			requisition.validate();
		} catch (final ValidationException e) {
			LogUtils.debugf(this, e, "error validating incoming requisition with foreign source '%s'", requisition.getForeignSource());
			throw getException(Status.BAD_REQUEST, e.getMessage());
		}
        debug("addOrReplaceRequisition: Adding requisition %s", requisition.getForeignSource());
        m_pendingForeignSourceRepository.save(requisition);
        return Response.ok(requisition).build();
    } finally {
        writeUnlock();
    }
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:26,代码来源:RequisitionRestService.java


注:本文中的javax.xml.bind.ValidationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。