Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Code cleanup / adding JavaDoc #485

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
* occurred.
*
* @author Ludger Overbeck
* @param <T> generic item.
* @param <S> generic item.
*/
public class ChunkLoggingListener<T, S> implements SkipListener<T, S>, ItemReadListener<T>, ItemProcessListener<T, S>,
ItemWriteListener<S> {
public class ChunkLoggingListener<T, S>
implements SkipListener<T, S>, ItemReadListener<T>, ItemProcessListener<T, S>, ItemWriteListener<S> {

private static final Logger LOG = LoggerFactory.getLogger(ChunkLoggingListener.class);

/**
* @param item the object to use.
* @return the string representation of the input.
*/
protected String itemToString(Object item) {

return item.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public class JsonUsernamePasswordAuthenticationFilter extends AbstractAuthentica

private boolean postOnly = true;

// REVIEW may-bee (hohwille) We have a centralized and custom-configured object mapper as spring bean. IMHO we should
// inject that instance here.
private ObjectMapper objectMapper = new ObjectMapper();

/**
Expand All @@ -88,9 +86,8 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ

final UsernameAndPasswordParser usernameAndPasswordParser = new UsernameAndPasswordParser(request);
usernameAndPasswordParser.parse();
UsernamePasswordAuthenticationToken authRequest =
new UsernamePasswordAuthenticationToken(usernameAndPasswordParser.getTrimmedUsername(),
usernameAndPasswordParser.getPassword());
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
usernameAndPasswordParser.getTrimmedUsername(), usernameAndPasswordParser.getPassword());
// authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
return getAuthenticationManager().authenticate(authRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public void init(FilterConfig filterConfig) throws ServletException {

}

/**
* Initialization, for development mode only.
*/
@PostConstruct
public void initialize() {

if (!this.enabled) {
String message =
"****** FILTER " + this.delegateFilter
+ " HAS BEEN DISABLED! THIS FEATURE SHOULD ONLY BE USED IN DEVELOPMENT MODE ******";
String message = "****** FILTER " + this.delegateFilter
+ " HAS BEEN DISABLED! THIS FEATURE SHOULD ONLY BE USED IN DEVELOPMENT MODE ******";
LOG.warn(message);
// CHECKSTYLE:OFF (for development only)
System.err.println(message);
Expand All @@ -65,8 +67,8 @@ public void initialize() {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {

if (this.enabled) {
this.delegateFilter.doFilter(request, response, chain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import io.oasp.module.jpa.dataaccess.api.AdvancedRevisionEntity;

//@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, SecurityFilterAutoConfiguration.class })
/**
* Class containing main method as an entry point for spring-boot based app.
*/
@SpringBootApplication(exclude = { EndpointAutoConfiguration.class })
@EntityScan(basePackages = { "io.oasp.gastronomy.restaurant" }, basePackageClasses = { AdvancedRevisionEntity.class })
@EnableGlobalMethodSecurity(jsr250Enabled = true)
public class SpringBootApp {

/**
* Entry point for spring-boot based app
* Entry point for spring-boot based app.
*
* @param args - arguments
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import io.oasp.module.jpa.dataaccess.api.AdvancedRevisionEntity;

@SpringBootApplication(exclude = {
EndpointAutoConfiguration.class,
SecurityAutoConfiguration.class,
SecurityFilterAutoConfiguration.class,
})
/**
* Class containing main method as an entry point for spring-boot based app.
*/
@SpringBootApplication(exclude = { EndpointAutoConfiguration.class, SecurityAutoConfiguration.class,
SecurityFilterAutoConfiguration.class, })
@EntityScan(basePackages = { "io.oasp.gastronomy.restaurant" }, basePackageClasses = { AdvancedRevisionEntity.class })
@EnableGlobalMethodSecurity(jsr250Enabled = false)
public class SpringBootBatchApp {
Expand All @@ -24,8 +24,8 @@ public class SpringBootBatchApp {
*
* @param args - arguments
*/
public static void main(String[] args) {
public static void main(String[] args) {

SpringApplication.run(SpringBootApp.class, args);
}
SpringApplication.run(SpringBootApp.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package io.oasp.gastronomy.restaurant.general.common.api;

import io.oasp.gastronomy.restaurant.general.common.api.datatype.Role;

import java.security.Principal;

import io.oasp.gastronomy.restaurant.general.common.api.datatype.Role;

/**
* This is the interface for the profile of a user interacting with this application. Currently this can only be a
* {@link io.oasp.gastronomy.restaurant.staffmanagement.dataaccess.api.StaffMemberEntity} however in the future a
* customer may login and make a reservation, etc.<br/>
* TODO: Also an external system may access the application via some service. Then there would be no user profile or it
* would be empty...
* This is the interface for the profile of a user interacting with this application.
*
* @author agreul
*/
public interface UserProfile extends Principal {
/**
Expand All @@ -22,6 +17,7 @@ public interface UserProfile extends Principal {
/**
* @return the unique login of the user for authentication and identification.
*/
@Override
String getName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ public abstract class BaseWebSecurityConfig extends WebSecurityConfigurerAdapter
@Value("${security.cors.enabled}")
boolean corsEnabled = false;

/**
* The {@link AuthenticationManagerBuilder} to inject.
*/
@Inject
protected AuthenticationManagerBuilder authenticationManagerBuilder;

/**
* The {@link ApplicationAuthenticationProvider} to inject.
*/
@Inject
protected ApplicationAuthenticationProvider authenticationProvider;

Expand Down Expand Up @@ -124,7 +130,7 @@ protected Filter getSimpleRestLogoutFilter() {
* status 200 instead of redirect after login.
*
* @return the AuthenticationFilter
* @throws Exception
* @throws Exception to pass over.
*/
protected JsonUsernamePasswordAuthenticationFilter getSimpleRestAuthenticationFilter() throws Exception {

Expand All @@ -143,7 +149,7 @@ protected JsonUsernamePasswordAuthenticationFilter getSimpleRestAuthenticationFi
/**
* Init the authenticationManager and simply set users and roles here (to keep things as simplistic as possible).
*
* @throws Exception
* @throws Exception to pass over.
*/
@PostConstruct
public void init() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class BeansDozerConfiguration {

private static final String DOZER_MAPPING_XML = "config/app/common/dozer-mapping.xml";

/**
* @return an instance of {@link DozerBeanMapper}.
*/
@Bean
public Mapper getDozer() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;

/**
* TODO hohwille This type ...
*
* @author hohwille
* By default Spring-Security is setting the prefix "ROLE_" for all permissions/authorities. This class offers the
* possibility to change this behavior to a wanted prefix using the constructor with a string parameter.
*/
public class DefaultRolesPrefixPostProcessor implements BeanPostProcessor, PriorityOrdered {

private final String rolePrefix;

/**
* Der Konstruktor.
* The constructor.
*
* @param rolePrefix das gewünschte Rollen-Präfix (z.B. der leere String).
* @param rolePrefix the role prefix to set (e.g. an empty string).
*/
public DefaultRolesPrefixPostProcessor(String rolePrefix) {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import io.oasp.module.rest.service.impl.RestServiceExceptionFacade;
import io.oasp.module.rest.service.impl.json.ObjectMapperFactory;

/**
* This configuration type registers various beans related to rest and web services.
*/
@Configuration
@EnableWs
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" /* , "classpath:META-INF/cxf/cxf-servlet.xml" */ })
Expand All @@ -40,14 +43,19 @@ public class ServiceConfiguration extends WsConfigurerAdapter {
/** Logger instance. */
private static final Logger LOG = LoggerFactory.getLogger(ServiceConfiguration.class);

@SuppressWarnings("javadoc")
public static final String URL_PATH_SERVICES = "/services";

@SuppressWarnings("javadoc")
public static final String URL_FOLDER_REST = "/rest";

@SuppressWarnings("javadoc")
public static final String URL_FOLDER_WEB_SERVICES = "/ws";

@SuppressWarnings("javadoc")
public static final String URL_PATH_REST_SERVICES = URL_PATH_SERVICES + URL_FOLDER_REST;

@SuppressWarnings("javadoc")
public static final String URL_PATH_WEB_SERVICES = URL_PATH_SERVICES + URL_FOLDER_WEB_SERVICES;

@Value("${security.expose.error.details}")
Expand All @@ -59,18 +67,27 @@ public class ServiceConfiguration extends WsConfigurerAdapter {
@Inject
private ObjectMapperFactory objectMapperFactory;

/**
* @return a {@link SpringBus} instance as bean with name "cxf".
*/
@Bean(name = "cxf")
public SpringBus springBus() {

return new SpringBus();
}

/**
* @return the {@link JacksonJsonProvider}.
*/
@Bean
public JacksonJsonProvider jacksonJsonProvider() {

return new JacksonJsonProvider(this.objectMapperFactory.createInstance());
}

/**
* @return the configured {@link ServletRegistrationBean}.
*/
@Bean
public ServletRegistrationBean servletRegistrationBean() {

Expand All @@ -79,6 +96,9 @@ public ServletRegistrationBean servletRegistrationBean() {
return servletRegistration;
}

/**
* @return a configured JAX RS {@link Server}.
*/
@Bean
public Server jaxRsServer() {

Expand Down Expand Up @@ -106,6 +126,9 @@ private Collection<Object> findRestServices() {
return this.applicationContext.getBeansWithAnnotation(Path.class).values();
}

/**
* @return the {@link RestServiceExceptionFacade}.
*/
@Bean
public RestServiceExceptionFacade restServiceExceptionFacade() {

Expand All @@ -115,6 +138,9 @@ public RestServiceExceptionFacade restServiceExceptionFacade() {
}

// BEGIN ARCHETYPE SKIP
/**
* @return an {@link Endpoint} at /TablemanagementWebService.
*/
@Bean
public Endpoint tableManagement() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.oasp.gastronomy.restaurant.offermanagement.service.impl.rest;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -180,14 +181,14 @@ public void updateProductPicture(long productId, BinaryObjectEto binaryObjectEto
public MultipartBody getProductPicture(long productId) throws SQLException, IOException {

Blob blob = this.offermanagement.findProductPictureBlob(productId);
// REVIEW arturk88 (hohwille) we need to find another way to stream the blob without loading into heap.
// https://github.com/oasp/oasp4j-sample/pull/45
byte[] data = IOUtils.readBytesFromStream(blob.getBinaryStream());

// byte[] data = IOUtils.readBytesFromStream(blob.getBinaryStream());
InputStream data = blob.getBinaryStream();

List<Attachment> atts = new LinkedList<>();
atts.add(new Attachment("binaryObjectEto", MediaType.APPLICATION_JSON,
this.offermanagement.findProductPicture(productId)));
atts.add(new Attachment("blob", MediaType.APPLICATION_OCTET_STREAM, new ByteArrayInputStream(data)));
atts.add(new Attachment("blob", MediaType.APPLICATION_OCTET_STREAM, new BufferedInputStream(data)));
return new MultipartBody(atts, true);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public interface OrderPosition extends ApplicationEntity {
@NotNull
OrderPositionState getState();

/**
* @return the current {@link ProductOrderState state}.
*/
ProductOrderState getMealState();

/**
* @return the current {@link ProductOrderState state}.
*/
ProductOrderState getSidedishState();

/**
* @return the current {@link ProductOrderState state}.
*/
Expand All @@ -82,6 +92,16 @@ public interface OrderPosition extends ApplicationEntity {
*/
void setState(OrderPositionState state);

/**
* @param mealState the new {@link #getMealState() state}.
*/
void setMealState(ProductOrderState mealState);

/**
* @param sidedishState the new {@link #getSidedishState() state}.
*/
void setSidedishState(ProductOrderState sidedishState);

/**
* @param drinkState the new {@link #getDrinkState() state}.
*/
Expand Down
Loading