Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.
Open
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
39 changes: 39 additions & 0 deletions order-service/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.devonfw.app.java</groupId>
<artifactId>order-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>order-service-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>API of the server for the order-service application (containing datatypes, transfer-objects, and service interfaces).</description>

<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>com.devonfw.java.modules</groupId>
<artifactId>devon4j-rest</artifactId>
</dependency>
<dependency>
<groupId>com.devonfw.java.modules</groupId>
<artifactId>devon4j-logging</artifactId>
</dependency>
<dependency>
<groupId>com.devonfw.java.modules</groupId>
<artifactId>devon4j-security</artifactId>
</dependency>
<!-- Required for secrutiy REST service -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.devonfw.app.java.order.general.common.api;

import com.devonfw.module.basic.common.api.entity.GenericEntity;

/**
* This is the abstract interface for a {@link GenericEntity} of this application. We are using {@link Long} for
* all {@link #getId() primary keys}.
*/
public abstract interface ApplicationEntity extends GenericEntity<Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.devonfw.app.java.order.general.common.api;

/**
* This is the interface for a {@link BinaryObject} of the order-service.
*/
public interface BinaryObject extends ApplicationEntity {

/**
* @param mimeType is the MIME-Type of this {@link BinaryObject}
*/
void setMimeType(String mimeType);

/**
* Returns MIME-Type of thie {@link BinaryObject}
*
* @return the MIME-Type, e.g image/jpeg
*/
String getMimeType();

/**
* @return Returns the size in bytes
*/
long getSize();

/**
* Sets the size of bytes
*
* @param size the size in bytes
*/
void setSize(long size);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.devonfw.app.java.order.general.common.api;

import net.sf.mmm.util.nls.api.NlsBundle;
import net.sf.mmm.util.nls.api.NlsBundleMessage;
import net.sf.mmm.util.nls.api.NlsMessage;

/**
* This is the {@link NlsBundle} for this application.
*/
public interface NlsBundleApplicationRoot extends NlsBundle {

/**
* @see com.devonfw.app.java.order.general.common.api.exception.NoActiveUserException
*
* @return the {@link NlsMessage}.
*/
@NlsBundleMessage("There is currently no user logged in")
NlsMessage errorNoActiveUser();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.devonfw.app.java.order.general.common.api;

/**
* This is the interface for the profile of a user interacting with this application.
*/
public interface UserProfile {

/**
* @return the login of the user.
*/
String getLogin();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.devonfw.app.java.order.general.common.api.exception;

import net.sf.mmm.util.nls.api.NlsMessage;

/**
* Abstract base class for business exceptions of this application.
*/
public abstract class ApplicationBusinessException extends ApplicationException {

private static final long serialVersionUID = 1L;

/**
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationBusinessException(NlsMessage message) {

super(message);
}

/**
* @param cause the error {@link #getCause() cause}.
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationBusinessException(Throwable cause, NlsMessage message) {

super(cause, message);
}

@Override
public boolean isTechnical() {

return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.devonfw.app.java.order.general.common.api.exception;

import net.sf.mmm.util.exception.api.NlsRuntimeException;
import net.sf.mmm.util.nls.api.NlsMessage;

/**
* Abstract base class for custom exceptions of this application.
*/
public abstract class ApplicationException extends NlsRuntimeException {

private static final long serialVersionUID = 1L;

/**
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationException(NlsMessage message) {

super(message);
}

/**
* @param cause the error {@link #getCause() cause}.
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationException(Throwable cause, NlsMessage message) {

super(cause, message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.devonfw.app.java.order.general.common.api.exception;

import net.sf.mmm.util.nls.api.NlsMessage;

/**
* Abstract base class for technical custom exceptions of this application.
*/
public abstract class ApplicationTechnicalException extends ApplicationException {

private static final long serialVersionUID = 1L;

/**
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationTechnicalException(NlsMessage message) {

super(message);
}

/**
* @param cause the error {@link #getCause() cause}.
* @param message the error {@link #getNlsMessage() message}.
*/
public ApplicationTechnicalException(Throwable cause, NlsMessage message) {

super(cause, message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.devonfw.app.java.order.general.common.api.exception;

import com.devonfw.app.java.order.general.common.api.NlsBundleApplicationRoot;

/**
* Thrown when an operation is requested that requires a user to be logged in, but no such user exists.
*/
public class NoActiveUserException extends ApplicationBusinessException {

/** UID for serialization. */
private static final long serialVersionUID = 1L;

/**
* The constructor.
*/
public NoActiveUserException() {

this(null);
}

/**
* The constructor.
*
* @param cause The root cause of this exception.
*/
public NoActiveUserException(Throwable cause) {

super(cause, createBundle(NlsBundleApplicationRoot.class).errorNoActiveUser());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.devonfw.app.java.order.general.common.api.to;

import com.devonfw.app.java.order.general.common.api.UserProfile;
import com.devonfw.module.basic.common.api.to.AbstractTo;

/**
* Implementation of {@link UserProfile} as {AbstractTo TO}.
*/
public class UserProfileTo extends AbstractTo implements UserProfile {

private static final long serialVersionUID = 1L;

private String login;

/**
* The constructor.
*/
public UserProfileTo() {

super();
}

@Override
public String getLogin() {

return this.login;
}

/**
* @param login the new {@link #getLogin() login}.
*/
public void setLogin(String login) {

this.login = login;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.devonfw.app.java.order.general.logic.api.to;

import com.devonfw.app.java.order.general.common.api.BinaryObject;
import com.devonfw.module.basic.common.api.to.AbstractEto;

/**
* The {@link com.devonfw.module.basic.common.api.to.AbstractEto ETO} for a {@link BinaryObject}.
*/
public class BinaryObjectEto extends AbstractEto implements BinaryObject {

private static final long serialVersionUID = 1L;

private String mimeType;

private long size;

/**
* Constructor.
*/
public BinaryObjectEto() {

super();
}

@Override
public void setMimeType(String mimeType) {

this.mimeType = mimeType;

}

@Override
public String getMimeType() {

return this.mimeType;
}

@Override
public long getSize() {

return this.size;
}

@Override
public void setSize(long size) {

this.size = size;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.devonfw.app.java.order.general.service.api.rest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

import org.springframework.security.web.csrf.CsrfToken;

import com.devonfw.module.rest.common.api.RestService;

import com.devonfw.app.java.order.general.common.api.to.UserProfileTo;

/**
* The security REST service provides access to the csrf token, the authenticated user's meta-data. Furthermore, it
* provides functionality to check permissions and roles of the authenticated user.
*/
@Path("/security/v1")
public interface SecurityRestService extends RestService {

/**
* @param request {@link HttpServletRequest} to retrieve the current session from.
* @param response {@link HttpServletResponse} to send additional information.
* @return the Spring Security {@link CsrfToken} from the server session.
*/
@GET
@Path("/csrftoken/")
CsrfToken getCsrfToken(@Context HttpServletRequest request, @Context HttpServletResponse response);

/**
* @return the {@link UserProfileTo} of the currently logged-in user.
*/
@GET
@Path("/currentuser/")
UserProfileTo getCurrentUser();

}
Loading