Consistent code formatting

This commit is contained in:
Stéphane Nicoll
2025-03-14 12:04:11 +01:00
parent 6e26108195
commit 1383efe898
64 changed files with 720 additions and 299 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,7 +24,8 @@ import java.util.Date;
import javax.xml.rpc.ServiceException;
/**
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-RPC (Axis 1).
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code>
* operations using JAX-RPC (Axis 1).
*
* @author Arjen Poutsma
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,7 +28,8 @@ import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
/**
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-WS.
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code>
* operations using JAX-WS.
*
* @author Arjen Poutsma
*/
@@ -41,7 +42,8 @@ public class JaxWsMain {
if (args.length == 0) {
service = new AirlineService();
} else {
}
else {
QName serviceName = new QName("http://www.springframework.org/spring-ws/samples/airline/definitions",
"AirlineService");
service = new AirlineService(new URL(args[0]), serviceName);
@@ -52,8 +54,8 @@ public class JaxWsMain {
GetFlightsRequest request = new GetFlightsRequest();
request.setFrom("AMS");
request.setTo("VCE");
XMLGregorianCalendar departureDate = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31,
DatatypeConstants.FIELD_UNDEFINED);
XMLGregorianCalendar departureDate = DatatypeFactory.newInstance()
.newXMLGregorianCalendarDate(2006, 1, 31, DatatypeConstants.FIELD_UNDEFINED);
request.setDepartureDate(departureDate);
System.out.format("Requesting flights on %1tD%n", departureDate.toGregorianCalendar());
@@ -75,7 +77,8 @@ public class JaxWsMain {
writeTicket(ticket);
}
} catch (SOAPFaultException ex) {
}
catch (SOAPFaultException ex) {
System.out.format("SOAP Fault Code %1s%n", ex.getFault().getFaultCodeAsQName());
System.out.format("SOAP Fault String: %1s%n", ex.getFault().getFaultString());
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,7 +21,9 @@ import javax.xml.transform.stream.StreamResult;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.xml.transform.StringSource;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public class JmsClient extends WebServiceGatewaySupport {
private static final String PAYLOAD = "<airline:GetFlightsRequest xmlns:airline=\"http://www.springframework.org/spring-ws/samples/airline/schemas/messages\">"
@@ -31,4 +33,5 @@ public class JmsClient extends WebServiceGatewaySupport {
public void getFlights() {
getWebServiceTemplate().sendSourceAndReceiveToResult(new StringSource(PAYLOAD), new StreamResult(System.out));
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,4 +43,5 @@ public class JmsConfiguration {
jmsClient.setMessageSender(messageSender);
return jmsClient;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -39,4 +39,5 @@ public class JmsMain {
client.getFlights();
};
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -79,7 +79,8 @@ public class GetFlights {
SOAPMessage response = connection.call(request, url);
if (!response.getSOAPBody().hasFault()) {
writeGetFlightsResponse(response);
} else {
}
else {
SOAPFault fault = response.getSOAPBody().getFault();
System.err.println("Received SOAP Fault");
System.err.println("SOAP Fault Code: " + fault.getFaultCode());
@@ -91,7 +92,8 @@ public class GetFlights {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name getFlightsResponseName = envelope.createName("GetFlightsResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement getFlightsResponseElement = (SOAPBodyElement) message.getSOAPBody()
.getChildElements(getFlightsResponseName).next();
.getChildElements(getFlightsResponseName)
.next();
Name flightName = envelope.createName("flight", PREFIX, NAMESPACE_URI);
Iterator iterator = getFlightsResponseElement.getChildElements(flightName);
Transformer transformer = transfomerFactory.newTransformer();
@@ -106,4 +108,5 @@ public class GetFlights {
transformer.transform(source, new StreamResult(System.out));
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,4 +38,5 @@ public class SaajMain {
GetFlights getFlights = new GetFlights(url);
getFlights.getFlights();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -40,22 +40,24 @@ public class GetFlights extends WebServiceGatewaySupport {
getFlightsRequest.setTo("VCE");
XMLGregorianCalendar departureDate = null;
try {
departureDate = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31,
DatatypeConstants.FIELD_UNDEFINED);
} catch (DatatypeConfigurationException e) {
departureDate = DatatypeFactory.newInstance()
.newXMLGregorianCalendarDate(2006, 1, 31, DatatypeConstants.FIELD_UNDEFINED);
}
catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
getFlightsRequest.setDepartureDate(departureDate);
System.out.println("Requesting flights on " + departureDate);
GetFlightsResponse response = null;
try {
response = (GetFlightsResponse) getWebServiceTemplate().marshalSendAndReceive(getFlightsRequest);
} catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println("Got " + response.getFlight().size() + " results");
GetFlightsResponse response = null;
try {
response = (GetFlightsResponse) getWebServiceTemplate().marshalSendAndReceive(getFlightsRequest);
}
catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println("Got " + response.getFlight().size() + " results");
if (response.getFlight().size() > 0) {
// Book the first flight using John Doe as a frequent flyer
BookFlightRequest bookFlightRequest = new BookFlightRequest();
@@ -66,7 +68,7 @@ public class GetFlights extends WebServiceGatewaySupport {
bookFlightRequest.setPassengers(passengers);
JAXBElement<Ticket> ticket = (JAXBElement<Ticket>) getWebServiceTemplate()
.marshalSendAndReceive(bookFlightRequest);
.marshalSendAndReceive(bookFlightRequest);
writeTicket(ticket.getValue());
}
@@ -92,11 +94,12 @@ public class GetFlights extends WebServiceGatewaySupport {
System.out.println(flight.getDepartureTime());
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
System.out.println("------------");
System.out.println(
"Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t" + flight.getDepartureTime());
System.out.println("Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t"
+ flight.getDepartureTime());
System.out.println("\t" + flight.getFrom().getCity());
System.out.println(
"Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t" + flight.getArrivalTime());
System.out.println("Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t"
+ flight.getArrivalTime());
System.out.println("\t" + flight.getTo().getCity());
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -36,4 +36,5 @@ public class GetFrequentFlyerMileage extends WebServiceGatewaySupport {
getWebServiceTemplate().sendSourceAndReceiveToResult(source, new StreamResult(System.out));
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,4 +33,5 @@ public class SpringWsMain {
GetFrequentFlyerMileage getFrequentFlyerMileage = ctx.getBean(GetFrequentFlyerMileage.class);
getFrequentFlyerMileage.getFrequentFlyerMileage();
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.client.sws;
import org.springframework.context.annotation.Bean;
@@ -56,4 +72,5 @@ public class WsConfiguration {
securityInterceptor.setSecurementPassword("changeme");
return securityInterceptor;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -34,7 +34,8 @@ import org.springframework.ws.test.client.MockWebServiceServer;
import org.springframework.xml.transform.StringSource;
/**
* This test illustrates the use of the client-side testing API, introduced in Spring-WS 2.0.
* This test illustrates the use of the client-side testing API, introduced in Spring-WS
* 2.0.
*
* @author Arjen Poutsma
*/
@@ -42,7 +43,8 @@ import org.springframework.xml.transform.StringSource;
@Import(WsConfiguration.class)
public class GetFlightsTest {
@Autowired GetFlights getFlights;
@Autowired
GetFlights getFlights;
private MockWebServiceServer mockServer;
@@ -58,8 +60,9 @@ public class GetFlightsTest {
@Test
public void getFlights() {
Source getFlightsRequest = new StringSource("<GetFlightsRequest xmlns='" + MESSAGES_NS + "'>" + "<from>AMS</from>"
+ "<to>VCE</to>" + "<departureDate>2006-01-31</departureDate>" + "</GetFlightsRequest>");
Source getFlightsRequest = new StringSource(
"<GetFlightsRequest xmlns='" + MESSAGES_NS + "'>" + "<from>AMS</from>" + "<to>VCE</to>"
+ "<departureDate>2006-01-31</departureDate>" + "</GetFlightsRequest>");
String flightInfo = "<t:number>KL1653</t:number>"
+ "<t:departureTime>2006-01-31T10:05:00.000+01:00</t:departureTime>"
@@ -81,9 +84,9 @@ public class GetFlightsTest {
Map<String, String> namespaces = Collections.singletonMap("m", MESSAGES_NS);
mockServer.expect(xpath("/m:BookFlightRequest/m:flightNumber", namespaces).exists())
.andExpect(xpath("/m:BookFlightRequest/m:departureTime", namespaces).exists())
.andExpect(xpath("/m:BookFlightRequest/m:passengers", namespaces).exists())
.andRespond(withPayload(bookFlightResponse));
.andExpect(xpath("/m:BookFlightRequest/m:departureTime", namespaces).exists())
.andExpect(xpath("/m:BookFlightRequest/m:passengers", namespaces).exists())
.andRespond(withPayload(bookFlightResponse));
getFlights.getFlights();

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline;
import org.springframework.boot.SpringApplication;
@@ -10,4 +26,5 @@ public class AirlineServerApplication {
public static void main(String[] args) {
SpringApplication.run(AirlineServerApplication.class, args);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.dao;
import org.springframework.data.repository.CrudRepository;

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.dao;
import java.time.ZoneId;
@@ -15,7 +31,8 @@ import org.springframework.ws.samples.airline.domain.ServiceClass;
public class Databaseinit {
@Bean
CommandLineRunner initializeDatabase(AirportDao airportDao, FlightDao flightDao, FrequentFlyerDao frequentFlyerDao) {
CommandLineRunner initializeDatabase(AirportDao airportDao, FlightDao flightDao,
FrequentFlyerDao frequentFlyerDao) {
return args -> {
Airport amsterdam = airportDao.save(new Airport("AMS", "Schiphol Airport", "Amsterdam"));
Airport venice = airportDao.save(new Airport("VCE", "Marco Polo Airport", "Venice"));
@@ -49,4 +66,5 @@ public class Databaseinit {
frequentFlyerDao.save(new FrequentFlyer("John", "Doe", "john", "changeme"));
};
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,4 +35,5 @@ public interface FlightDao extends CrudRepository<Flight, Long> {
@Param("class") ServiceClass serviceClass);
Flight findFlightByNumberAndDepartureTime(String flightNumber, ZonedDateTime departureTime);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,13 +28,17 @@ import java.io.Serializable;
public class Airport implements Serializable {
@Id
@Column(name = "CODE") private String code;
@Column(name = "CODE")
private String code;
@Column(name = "NAME") private String name;
@Column(name = "NAME")
private String name;
@Column(name = "CITY") private String city;
@Column(name = "CITY")
private String city;
public Airport() {}
public Airport() {
}
public Airport(String code, String name, String city) {
this.code = code;
@@ -68,4 +72,5 @@ public class Airport implements Serializable {
public int hashCode() {
return code.hashCode();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005, 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,30 +28,40 @@ public class Flight implements Serializable {
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "NUMBER") private String number;
@Column(name = "NUMBER")
private String number;
@Column(name = "DEPARTURE_TIME")
@Persistent private ZonedDateTime departureTime;
@Persistent
private ZonedDateTime departureTime;
@ManyToOne
@JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false) private Airport from;
@JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false)
private Airport from;
@Column(name = "ARRIVAL_TIME")
@Persistent private ZonedDateTime arrivalTime;
@Persistent
private ZonedDateTime arrivalTime;
@ManyToOne
@JoinColumn(name = "TO_AIRPORT_CODE", nullable = false) private Airport to;
@JoinColumn(name = "TO_AIRPORT_CODE", nullable = false)
private Airport to;
@Column(name = "SERVICE_CLASS")
@Enumerated(EnumType.STRING) private ServiceClass serviceClass;
@Enumerated(EnumType.STRING)
private ServiceClass serviceClass;
@Column(name = "SEATS_AVAILABLE") private int seatsAvailable;
@Column(name = "SEATS_AVAILABLE")
private int seatsAvailable;
@Column(name = "MILES") private int miles;
@Column(name = "MILES")
private int miles;
public Flight() {}
public Flight() {
}
public Flight(Long id) {
this.id = id;
@@ -154,4 +164,5 @@ public class Flight implements Serializable {
public String toString() {
return getNumber() + " " + getDepartureTime();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,13 +26,17 @@ import jakarta.persistence.Table;
@PrimaryKeyJoinColumn(name = "PASSENGER_ID")
public class FrequentFlyer extends Passenger {
@Column(name = "USERNAME") private String username;
@Column(name = "USERNAME")
private String username;
@Column(name = "PASSWORD") private String password;
@Column(name = "PASSWORD")
private String password;
@Column(name = "MILES") private int miles;
@Column(name = "MILES")
private int miles;
public FrequentFlyer() {}
public FrequentFlyer() {
}
public FrequentFlyer(String username) {
this.username = username;
@@ -94,4 +98,5 @@ public class FrequentFlyer extends Passenger {
public void addMiles(int miles) {
this.miles += miles;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005, 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,13 +26,17 @@ public class Passenger implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID") private Long id;
@Column(name = "ID")
private Long id;
@Column(name = "FIRST_NAME") private String firstName;
@Column(name = "FIRST_NAME")
private String firstName;
@Column(name = "LAST_NAME") private String lastName;
@Column(name = "LAST_NAME")
private String lastName;
public Passenger() {}
public Passenger() {
}
public Passenger(String firstName, String lastName) {
this.firstName = firstName;
@@ -86,4 +90,5 @@ public class Passenger implements Serializable {
result = 29 * result + getLastName().hashCode();
return result;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,9 +18,10 @@ package org.springframework.ws.samples.airline.domain;
public enum ServiceClass {
ECONOMY,
ECONOMY,
BUSINESS,
BUSINESS,
FIRST
FIRST
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,19 +30,24 @@ import org.springframework.data.annotation.Persistent;
public class Ticket implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "ISSUE_DATE")
@Persistent private LocalDate issueDate;
@Persistent
private LocalDate issueDate;
@ManyToOne
@JoinColumn(name = "FLIGHT_ID", nullable = false) private Flight flight;
@JoinColumn(name = "FLIGHT_ID", nullable = false)
private Flight flight;
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinTable(name = "PASSENGER_TICKET", joinColumns = @JoinColumn(name = "TICKET_ID"), inverseJoinColumns = @JoinColumn(
name = "PASSENGER_ID")) private Set<Passenger> passengers = new HashSet<Passenger>();
@JoinTable(name = "PASSENGER_TICKET", joinColumns = @JoinColumn(name = "TICKET_ID"),
inverseJoinColumns = @JoinColumn(name = "PASSENGER_ID"))
private Set<Passenger> passengers = new HashSet<Passenger>();
public Ticket() {}
public Ticket() {
}
public Ticket(Long id) {
this.id = id;
@@ -79,4 +84,5 @@ public class Ticket implements Serializable {
public void addPassenger(Passenger passenger) {
passengers.add(passenger);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.jms;
import jakarta.jms.ConnectionFactory;
@@ -30,7 +46,8 @@ public class JmsConfiguration {
}
/**
* Listen for JMS messages and route them into the SOAP-based {@link WebServiceMessageListener}.
* Listen for JMS messages and route them into the SOAP-based
* {@link WebServiceMessageListener}.
*/
@Bean
DefaultMessageListenerContainer containerFactory(ConnectionFactory connectionFactory,
@@ -52,4 +69,5 @@ public class JmsConfiguration {
messageListener.setMessageReceiver(messageReceiver);
return messageListener;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,10 +30,13 @@ import javax.xml.datatype.XMLGregorianCalendar;
import org.springframework.ws.samples.airline.domain.Passenger;
import org.springframework.ws.samples.airline.schema.*;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public abstract class SchemaConversionUtils {
private SchemaConversionUtils() {}
private SchemaConversionUtils() {
}
public static Flight toSchemaType(org.springframework.ws.samples.airline.domain.Flight domainFlight)
throws DatatypeConfigurationException {
@@ -51,14 +54,15 @@ public abstract class SchemaConversionUtils {
public static List<Flight> toSchemaType(List<org.springframework.ws.samples.airline.domain.Flight> domainFlights) {
return domainFlights.stream() //
.map(flight -> {
try {
return toSchemaType(flight);
} catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}) //
.collect(Collectors.toList());
.map(flight -> {
try {
return toSchemaType(flight);
}
catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}) //
.collect(Collectors.toList());
}
public static XMLGregorianCalendar toXMLGregorianCalendar(ZonedDateTime dateTime)
@@ -72,7 +76,8 @@ public abstract class SchemaConversionUtils {
return calendar.toGregorianCalendar().toZonedDateTime();
}
public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate) throws DatatypeConfigurationException {
public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate)
throws DatatypeConfigurationException {
DatatypeFactory factory = DatatypeFactory.newInstance();
return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthValue(),
@@ -148,4 +153,5 @@ public abstract class SchemaConversionUtils {
}
return schemaTicket;
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.security;
import java.util.Collection;
@@ -11,7 +27,7 @@ import org.springframework.ws.samples.airline.domain.FrequentFlyer;
public class FrequentFlyerDetails implements UserDetails {
private static final List<GrantedAuthority> GRANTED_AUTHORITIES = List
.of(new SimpleGrantedAuthority("ROLE_FREQUENT_FLYER"));
.of(new SimpleGrantedAuthority("ROLE_FREQUENT_FLYER"));
private FrequentFlyer frequentFlyer;
@@ -62,4 +78,5 @@ public class FrequentFlyerDetails implements UserDetails {
public String toString() {
return "FrequentFlyerDetails{" + "frequentFlyer=" + frequentFlyer + '}';
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.security;
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
@@ -12,17 +28,17 @@ public interface FrequentFlyerSecurityService {
/**
* Returns the <code>FrequentFlyer</code> with the given username.
*
* @param username the username
* @return the frequent flyer with the given username, or <code>null</code> if not found
* @return the frequent flyer with the given username, or <code>null</code> if not
* found
* @throws NoSuchFrequentFlyerException when the frequent flyer cannot be found
*/
FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException;
/**
* Returns the <code>FrequentFlyer</code> that is currently logged in.
*
* @return the frequent flyer that is currently logged in, or <code>null</code> if not found
* @return the frequent flyer that is currently logged in, or <code>null</code> if not
* found
*/
FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer();

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.security;
import org.springframework.context.annotation.Bean;
@@ -23,15 +39,16 @@ public class SecurityConfiguration {
return NoOpPasswordEncoder.getInstance();
}
// @Bean
// SecurityFilterChain securityFilterChain(HttpSecurity security) throws Exception {
//
// security.authorizeHttpRequests() //
// .requestMatchers("/login", "/error", "/logout").permitAll() //
// .anyRequest().authenticated() //
// .and() //
// .csrf().disable();
//
// return security.build();
// }
// @Bean
// SecurityFilterChain securityFilterChain(HttpSecurity security) throws Exception {
//
// security.authorizeHttpRequests() //
// .requestMatchers("/login", "/error", "/logout").permitAll() //
// .anyRequest().authenticated() //
// .and() //
// .csrf().disable();
//
// return security.build();
// }
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.security;
import org.apache.wss4j.common.principal.UsernameTokenPrincipal;
@@ -32,7 +48,7 @@ public class SpringSecurityFrequentFlyerService implements FrequentFlyerSecurity
@Transactional
public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
return frequentFlyerDao.findByUsername(username) //
.orElseThrow(() -> new NoSuchFrequentFlyerException(username));
.orElseThrow(() -> new NoSuchFrequentFlyerException(username));
}
@Override
@@ -55,11 +71,12 @@ public class SpringSecurityFrequentFlyerService implements FrequentFlyerSecurity
log.debug("Looking up " + username);
FrequentFlyerDetails details = frequentFlyerDao.findByUsername(username) //
.map(FrequentFlyerDetails::new) //
.orElseThrow(() -> new UsernameNotFoundException("Frequent flyer '" + username + "' not found"));
.map(FrequentFlyerDetails::new) //
.orElseThrow(() -> new UsernameNotFoundException("Frequent flyer '" + username + "' not found"));
log.debug("Found " + details);
return details;
}
}

View File

@@ -1,12 +1,29 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.security;
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
/**
* Stub implementation of <code>FrequentFlyerSecurityService</code>. This implementation is used by default by
* {@link org.springframework.ws.samples.airline.service.impl.AirlineServiceImpl}, to allow it to run without depending
* on Spring Security.
* Stub implementation of <code>FrequentFlyerSecurityService</code>. This implementation
* is used by default by
* {@link org.springframework.ws.samples.airline.service.impl.AirlineServiceImpl}, to
* allow it to run without depending on Spring Security.
*
* @author Arjen Poutsma
*/
@@ -23,7 +40,8 @@ public class StubFrequentFlyerSecurityService implements FrequentFlyerSecuritySe
public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
if (john.getUsername().equals(username)) {
return john;
} else {
}
else {
throw new NoSuchFrequentFlyerException(username);
}
}
@@ -32,4 +50,5 @@ public class StubFrequentFlyerSecurityService implements FrequentFlyerSecuritySe
public FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer() {
return john;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,16 +29,16 @@ public interface AirlineService {
/**
* Returns a single <code>Flight</code> with the given id.
*
* @param id the flight identifier
* @return the flight
* @throws NoSuchFlightException if a flight with the specified flight iddoes not exist
* @throws NoSuchFlightException if a flight with the specified flight iddoes not
* exist
*/
Flight getFlight(Long id) throws NoSuchFlightException;
/**
* Returns a list of <code>Flight</code> objects that fall within the specified criteria.
*
* Returns a list of <code>Flight</code> objects that fall within the specified
* criteria.
* @param fromAirportCode the three-letter airport code to get flights from
* @param toAirportCode the three-letter airport code to get flights to
* @param departureDate the date of the flights
@@ -49,28 +49,31 @@ public interface AirlineService {
ServiceClass serviceClass);
/**
* Books a single flight for a number of passengers. Passengers can be either specified by name or by frequent flyer
* username. If a {@link FrequentFlyer} is specified, the first and last name are looked up in the database.
*
* Books a single flight for a number of passengers. Passengers can be either
* specified by name or by frequent flyer username. If a {@link FrequentFlyer} is
* specified, the first and last name are looked up in the database.
* @param flightNumber the number of the flight to book
* @param departureTime the departure time of the flight to book
* @param passengers the list of passengers for the flight to book. Can be either {@link Passenger} objects with a
* first and last name, or {@link FrequentFlyer} objects with a username.
* @param passengers the list of passengers for the flight to book. Can be either
* {@link Passenger} objects with a first and last name, or {@link FrequentFlyer}
* objects with a username.
* @return the created ticket
* @throws NoSuchFlightException if a flight with the specified flight number and departure time does not exist
* @throws NoSuchFlightException if a flight with the specified flight number and
* departure time does not exist
* @throws NoSeatAvailableException if not enough seats are available for the flight
* @throws NoSuchFrequentFlyerException if a specified {@link FrequentFlyer} cannot be found
* @throws NoSuchFrequentFlyerException if a specified {@link FrequentFlyer} cannot be
* found
* @see Passenger
* @see FrequentFlyer
*/
Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List<Passenger> passengers)
throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException;
/**
* Returns the amount of frequent flyer award miles for the currently logged in frequent flyer.
*
* @return the amount of frequent flyer miles
*/
int getFrequentFlyerMileage();
}
/**
* Returns the amount of frequent flyer award miles for the currently logged in
* frequent flyer.
* @return the amount of frequent flyer miles
*/
int getFrequentFlyerMileage();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,14 +28,15 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
@SoapFault(faultCode = FaultCode.SERVER)
public class NoSeatAvailableException extends Exception {
private Flight flight;
private Flight flight;
public NoSeatAvailableException(Flight flight) {
super("Flight [" + flight + "] has not more seats available");
this.flight = flight;
}
public NoSeatAvailableException(Flight flight) {
super("Flight [" + flight + "] has not more seats available");
this.flight = flight;
}
public Flight getFlight() {
return flight;
}
public Flight getFlight() {
return flight;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,25 +29,26 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
@SoapFault(faultCode = FaultCode.CLIENT)
public class NoSuchFlightException extends Exception {
private String flightNumber;
private String flightNumber;
private ZonedDateTime departureTime;
private ZonedDateTime departureTime;
public NoSuchFlightException(String flightNumber, ZonedDateTime departureTime) {
super("No flight with number [" + flightNumber + "] and departure time [" + departureTime + "]");
this.flightNumber = flightNumber;
this.departureTime = departureTime;
}
public NoSuchFlightException(String flightNumber, ZonedDateTime departureTime) {
super("No flight with number [" + flightNumber + "] and departure time [" + departureTime + "]");
this.flightNumber = flightNumber;
this.departureTime = departureTime;
}
public NoSuchFlightException(Long id) {
super("No flight with id [" + id + "]");
}
public NoSuchFlightException(Long id) {
super("No flight with id [" + id + "]");
}
public String getFlightNumber() {
return flightNumber;
}
public String getFlightNumber() {
return flightNumber;
}
public ZonedDateTime getDepartureTime() {
return departureTime;
}
public ZonedDateTime getDepartureTime() {
return departureTime;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,14 +28,15 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
@SoapFault(faultCode = FaultCode.CLIENT)
public class NoSuchFrequentFlyerException extends Exception {
private String username;
private String username;
public NoSuchFrequentFlyerException(String username) {
super("No frequent flyer with name [" + username + "]");
this.username = username;
}
public NoSuchFrequentFlyerException(String username) {
super("No frequent flyer with name [" + username + "]");
this.username = username;
}
public String getusername() {
return username;
}
public String getusername() {
return username;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -65,8 +65,8 @@ public class AirlineServiceImpl implements AirlineService {
this.frequentFlyerSecurityService = frequentFlyerSecurityService;
}
@Transactional(readOnly = false,
rollbackFor = { NoSuchFlightException.class, NoSeatAvailableException.class, NoSuchFrequentFlyerException.class })
@Transactional(readOnly = false, rollbackFor = { NoSuchFlightException.class, NoSeatAvailableException.class,
NoSuchFrequentFlyerException.class })
public Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List<Passenger> passengers)
throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException {
@@ -80,7 +80,8 @@ public class AirlineServiceImpl implements AirlineService {
if (flight == null) {
throw new NoSuchFlightException(flightNumber, departureTime);
} else if (flight.getSeatsAvailable() < passengers.size()) {
}
else if (flight.getSeatsAvailable() < passengers.size()) {
throw new NoSeatAvailableException(flight);
}
@@ -95,7 +96,8 @@ public class AirlineServiceImpl implements AirlineService {
FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getFrequentFlyer(username);
frequentFlyer.addMiles(flight.getMiles());
ticket.addPassenger(frequentFlyer);
} else {
}
else {
ticket.addPassenger(passenger);
}
}
@@ -111,7 +113,7 @@ public class AirlineServiceImpl implements AirlineService {
public Flight getFlight(Long id) throws NoSuchFlightException {
return flightDao.findById(id) //
.orElseThrow(() -> new NoSuchFlightException(id));
.orElseThrow(() -> new NoSuchFlightException(id));
}
public List<Flight> getFlights(String fromAirportCode, String toAirportCode, ZonedDateTime departureDate,
@@ -122,7 +124,8 @@ public class AirlineServiceImpl implements AirlineService {
}
if (logger.isDebugEnabled()) {
logger.debug("Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate);
logger
.debug("Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate);
}
List<Flight> flights = flightDao.findFlights(fromAirportCode, toAirportCode, departureDate, serviceClass);
@@ -143,7 +146,8 @@ public class AirlineServiceImpl implements AirlineService {
}
return Optional.ofNullable(frequentFlyerSecurityService.getCurrentlyAuthenticatedFrequentFlyer())
.map(FrequentFlyer::getMiles) //
.orElse(0);
.map(FrequentFlyer::getMiles) //
.orElse(0);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,7 +32,9 @@ import org.springframework.ws.samples.airline.domain.ServiceClass;
import org.springframework.ws.samples.airline.service.AirlineService;
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
@Controller
@RequestMapping("/flights")
public class FlightsController {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2011 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -50,8 +50,8 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Endpoint that handles the Airline Web Service messages using a combination of JAXB2 marshalling and XPath
* expressions.
* Endpoint that handles the Airline Web Service messages using a combination of JAXB2
* marshalling and XPath expressions.
*
* @author Arjen Poutsma
*/
@@ -72,9 +72,8 @@ public class AirlineEndpoint {
}
/**
* This endpoint method uses a combination of XPath expressions and marshalling to handle message with a
* <code>&lt;GetFlightsRequest&gt;</code> payload.
*
* This endpoint method uses a combination of XPath expressions and marshalling to
* handle message with a <code>&lt;GetFlightsRequest&gt;</code> payload.
* @param from the from airport
* @param to the to airport
* @param departureDateString the string representation of the departure date
@@ -110,8 +109,8 @@ public class AirlineEndpoint {
}
/**
* This endpoint method uses marshalling to handle message with a <code>&lt;BookFlightRequest&gt;</code> payload.
*
* This endpoint method uses marshalling to handle message with a
* <code>&lt;BookFlightRequest&gt;</code> payload.
* @param request the JAXB2 representation of a <code>&lt;BookFlightRequest&gt;</code>
* @return the JAXB2 representation of a <code>&lt;BookFlightResponse&gt;</code>
*/
@@ -121,8 +120,8 @@ public class AirlineEndpoint {
DatatypeConfigurationException, NoSuchFlightException, NoSuchFrequentFlyerException {
if (logger.isDebugEnabled()) {
logger.debug("Received BookingFlightRequest '" + request.getFlightNumber() + "' on '" + request.getDepartureTime()
+ "' for " + request.getPassengers().getPassengerOrUsername());
logger.debug("Received BookingFlightRequest '" + request.getFlightNumber() + "' on '"
+ request.getDepartureTime() + "' for " + request.getPassengers().getPassengerOrUsername());
}
Ticket ticket = bookSchemaFlight(request.getFlightNumber(), request.getDepartureTime(),
@@ -145,7 +144,8 @@ public class AirlineEndpoint {
if (passengerOrUsername instanceof Name passengerName) {
Passenger passenger = new Passenger(passengerName.getFirst(), passengerName.getLast());
passengers.add(passenger);
} else if (passengerOrUsername instanceof String frequentFlyerUsername) {
}
else if (passengerOrUsername instanceof String frequentFlyerUsername) {
FrequentFlyer frequentFlyer = new FrequentFlyer(frequentFlyerUsername);
passengers.add(frequentFlyer);
}
@@ -173,4 +173,5 @@ public class AirlineEndpoint {
return response;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,16 +16,19 @@
package org.springframework.ws.samples.airline.ws;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public interface AirlineWebServiceConstants {
String BOOK_FLIGHT_REQUEST = "BookFlightRequest";
String BOOK_FLIGHT_REQUEST = "BookFlightRequest";
String GET_FLIGHTS_REQUEST = "GetFlightsRequest";
String GET_FLIGHTS_REQUEST = "GetFlightsRequest";
String GET_FREQUENT_FLYER_MILEAGE_RESPONSE = "GetFrequentFlyerMileageResponse";
String GET_FREQUENT_FLYER_MILEAGE_RESPONSE = "GetFrequentFlyerMileageResponse";
String MESSAGES_NAMESPACE = "http://www.springframework.org/spring-ws/samples/airline/schemas/messages";
String MESSAGES_NAMESPACE = "http://www.springframework.org/spring-ws/samples/airline/schemas/messages";
String GET_FREQUENT_FLYER_MILEAGE_REQUEST = "GetFrequentFlyerMileageRequest";
String GET_FREQUENT_FLYER_MILEAGE_REQUEST = "GetFrequentFlyerMileageRequest";
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.airline.ws;
import javax.security.auth.callback.CallbackHandler;
@@ -60,8 +76,10 @@ public class WebServicesConfiguration {
Wss4jSecurityInterceptor securityInterceptor(SpringSecurityPasswordValidationCallbackHandler handler) {
/**
* <xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
* <xwss:RequireUsernameToken passwordDigestRequired="true" nonceRequired="true"/> </xwss:SecurityConfiguration>
* <xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss=
* "http://java.sun.com/xml/ns/xwss/config">
* <xwss:RequireUsernameToken passwordDigestRequired="true" nonceRequired="true"/>
* </xwss:SecurityConfiguration>
*/
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setValidationActions("UsernameToken");
@@ -73,7 +91,8 @@ public class WebServicesConfiguration {
@Bean
PayloadRootSmartSoapEndpointInterceptor smartSoapEndpointInterceptor(Wss4jSecurityInterceptor securityInterceptor) {
return new PayloadRootSmartSoapEndpointInterceptor(securityInterceptor,
"http://www.springframework.org/spring-ws/samples/airline/schemas/messages", "GetFrequentFlyerMileageRequest");
"http://www.springframework.org/spring-ws/samples/airline/schemas/messages",
"GetFrequentFlyerMileageRequest");
}
@Bean

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -68,7 +68,8 @@ public class EchoClient {
SOAPMessage response = connection.call(request, url);
if (!response.getSOAPBody().hasFault()) {
writeEchoResponse(response);
} else {
}
else {
SOAPFault fault = response.getSOAPBody().getFault();
logger.error("Received SOAP Fault");
logger.error("SOAP Fault Code :" + fault.getFaultCode());
@@ -80,9 +81,11 @@ public class EchoClient {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name echoResponseName = envelope.createName("echoResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement echoResponseElement = (SOAPBodyElement) message.getSOAPBody().getChildElements(echoResponseName)
.next();
SOAPBodyElement echoResponseElement = (SOAPBodyElement) message.getSOAPBody()
.getChildElements(echoResponseName)
.next();
String echoValue = echoResponseElement.getTextContent();
logger.info("Echo Response [" + echoValue + "]");
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.echo.client.saaj;
import jakarta.xml.soap.SOAPException;
@@ -21,4 +37,5 @@ public class SaajEchoClient {
EchoClient echoClient = new EchoClient(url);
echoClient.callWebService();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -47,4 +47,5 @@ public class EchoClient extends WebServiceGatewaySupport {
logger.info(result.toString());
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,4 +38,5 @@ public class SpringWsEchoClient {
echoClient.echo();
};
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.echo;
import org.springframework.boot.SpringApplication;
@@ -9,4 +25,5 @@ public class EchoApplication {
public static void main(String[] args) {
SpringApplication.run(EchoApplication.class, args);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2014 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -64,4 +64,5 @@ public class EchoConfig extends WsConfigurerAdapter {
return definition;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,8 +26,8 @@ public interface EchoService {
/**
* Returns the given string.
*
* @return <code>message</code>
*/
String echo(String message);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -31,4 +31,5 @@ public class EchoServiceImpl implements EchoService {
public String echo(String message) {
return message;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,7 +33,8 @@ import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
/**
* Simple echoing Web service endpoint. Uses a <code>EchoService</code> to create a response string.
* Simple echoing Web service endpoint. Uses a <code>EchoService</code> to create a
* response string.
*
* @author Ingo Siebert
* @author Arjen Poutsma
@@ -66,7 +67,6 @@ public class EchoEndpoint {
/**
* Reads the given <code>requestElement</code>, and sends a the response back.
*
* @param requestElement the contents of the SOAP message as DOM elements
* @return the response element
*/
@@ -101,4 +101,5 @@ public class EchoEndpoint {
return responseElement;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -68,4 +68,5 @@ public class EchoEndpointTest {
verify(echoServiceMock);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.mtom.client.sws;
import org.springframework.context.annotation.Bean;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,8 +35,8 @@ import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
/**
* Simple client that demonstrates MTOM by invoking {@code StoreImage} and {@code LoadImage} using a WebServiceTemplate
* and SAAJ.
* Simple client that demonstrates MTOM by invoking {@code StoreImage} and
* {@code LoadImage} using a WebServiceTemplate and SAAJ.
*
* @author Tareq Abed Rabbo
* @author Arjen Poutsma
@@ -60,6 +60,7 @@ public class SaajMtomClient extends WebServiceGatewaySupport {
private static final Logger logger = LoggerFactory.getLogger(SaajMtomClient.class);
private ObjectFactory objectFactory = new ObjectFactory();
private StopWatch stopWatch = new StopWatch(ClassUtils.getShortName(getClass()));
public SaajMtomClient(SaajSoapMessageFactory messageFactory) {
@@ -71,8 +72,8 @@ public class SaajMtomClient extends WebServiceGatewaySupport {
StoreContentRequest storeContentRequest = this.objectFactory.createStoreContentRequest();
storeContentRequest.setName("spring-ws-logo");
storeContentRequest
.setContent(new DataHandler(Thread.currentThread().getContextClassLoader().getResource("spring-ws-logo.png")));
storeContentRequest.setContent(
new DataHandler(Thread.currentThread().getContextClassLoader().getResource("spring-ws-logo.png")));
this.stopWatch.start("store");
@@ -96,7 +97,7 @@ public class SaajMtomClient extends WebServiceGatewaySupport {
this.stopWatch.start("load");
LoadContentResponse loadContentResponse = (LoadContentResponse) getWebServiceTemplate()
.marshalSendAndReceive(loadContentRequest);
.marshalSendAndReceive(loadContentRequest);
this.stopWatch.stop();
@@ -132,4 +133,5 @@ public class SaajMtomClient extends WebServiceGatewaySupport {
return size;
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.mtom;
import org.springframework.boot.SpringApplication;
@@ -9,4 +25,5 @@ public class MtomServer {
public static void main(String[] args) {
SpringApplication.run(MtomServer.class, args);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.samples.mtom.config;
import java.util.Collections;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,7 +21,9 @@ import jakarta.activation.DataHandler;
import java.io.File;
import java.io.IOException;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public interface ContentRepository {
File loadContent(String name);

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
@Service
class ContentRepositoryImpl implements ContentRepository {
@@ -56,4 +58,5 @@ class ContentRepositoryImpl implements ContentRepository {
}
logger.info("Content stored.");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2012 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,7 +30,9 @@ import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
@Endpoint
public class ContentRepositoryEndpoint {

14
pom.xml
View File

@@ -40,6 +40,7 @@
<jaxws-tools.version>3.0.2</jaxws-tools.version>
<jdom.version>2.0.6.1</jdom.version>
<jws-api.version>3.0.0</jws-api.version>
<spring-javaformat.version>0.0.43</spring-javaformat.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<xmlschema.version>2.3.1</xmlschema.version>
</properties>
@@ -125,6 +126,19 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mycompany.hr;
import org.springframework.boot.SpringApplication;
@@ -9,4 +25,5 @@ public class HrApplication {
public static void main(String[] args) {
SpringApplication.run(HrApplication.class, args);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mycompany.hr.config;
import org.springframework.context.annotation.Bean;
@@ -30,4 +46,5 @@ public class HRConfiguration {
collection.setInline(true);
return collection;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,20 +19,19 @@ package com.mycompany.hr.service;
import java.util.Date;
/**
* This interface defined the contract for a HR business service. It is used by the {@link
* com.mycompany.hr.ws.HolidayEndpoint}.
* This interface defined the contract for a HR business service. It is used by the
* {@link com.mycompany.hr.ws.HolidayEndpoint}.
*
* @author Arjen Poutsma
*/
public interface HumanResourceService {
/**
* Books a holiday.
*
* @param startDate the start date of the holiday
* @param endDate the end date of the holiday
* @param name the name of the person taking the holiday
*/
void bookHoliday(Date startDate, Date endDate, String name);
/**
* Books a holiday.
* @param startDate the start date of the holiday
* @param endDate the end date of the holiday
* @param name the name of the person taking the holiday
*/
void bookHoliday(Date startDate, Date endDate, String name);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,16 +24,18 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Simple stub implementation of {@link HumanResourceService}, which does nothing but logging.
* Simple stub implementation of {@link HumanResourceService}, which does nothing but
* logging.
*
* @author Arjen Poutsma
*/
@Service
public class StubHumanResourceService implements HumanResourceService {
private static final Log logger = LogFactory.getLog(StubHumanResourceService.class);
private static final Log logger = LogFactory.getLog(StubHumanResourceService.class);
public void bookHoliday(Date startDate, Date endDate, String name) {
logger.info("Booking holiday for [" + startDate + "-" + endDate + "] for [" + name + "] ");
}
public void bookHoliday(Date startDate, Date endDate, String name) {
logger.info("Booking holiday for [" + startDate + "-" + endDate + "] for [" + name + "] ");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,8 +33,9 @@ import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import com.mycompany.hr.service.HumanResourceService;
/**
* This endpoint handles holiday requests. It uses a combination of JDOM and XPath to extract interesting pieces of XML
* from the incoming message, and invoked the injected {@link HumanResourceService} with those.
* This endpoint handles holiday requests. It uses a combination of JDOM and XPath to
* extract interesting pieces of XML from the incoming message, and invoked the injected
* {@link HumanResourceService} with those.
*
* @author Arjen Poutsma
*/
@@ -83,7 +84,8 @@ public class HolidayEndpoint {
if (result != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
return dateFormat.parse(result.getText());
} else {
}
else {
throw new IllegalArgumentException("Could not evaluate [" + expression + "] on [" + element + "]");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2010 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -48,7 +48,8 @@ public class HolidayEndpointTest {
InputStream is = getClass().getResourceAsStream("holidayRequest.xml");
try {
holidayRequest = builder.build(is);
} finally {
}
finally {
is.close();
}
endpoint = new HolidayEndpoint(serviceMock);