partey woka update
This commit is contained in:
parent
1c85f2b0fd
commit
8583bec0c6
@ -80,6 +80,18 @@ public class UserManager implements UserDataProvider {
|
||||
return userRepository.findOne(qUser.username.equalsIgnoreCase(username)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by bstly email.
|
||||
*
|
||||
* @param email the email
|
||||
* @return the by bstly email
|
||||
*/
|
||||
public User getByBstlyEmail(String email) {
|
||||
String username = email.replace("@"
|
||||
+ userEmailDomain, "");
|
||||
return getByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by reset token.
|
||||
*
|
||||
|
1863
partey/resources/woka.json
Normal file
1863
partey/resources/woka.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,14 +21,18 @@ import com.beust.jcommander.internal.Lists;
|
||||
import de.bstly.we.businesslogic.PermissionManager;
|
||||
import de.bstly.we.businesslogic.UserManager;
|
||||
import de.bstly.we.model.User;
|
||||
import de.bstly.we.partey.api.controller.model.CharacterTexture;
|
||||
import de.bstly.we.partey.api.controller.model.MemberData;
|
||||
import de.bstly.we.partey.api.controller.support.DebugLogger;
|
||||
import de.bstly.we.partey.api.controller.support.WokaListManager;
|
||||
import de.bstly.we.partey.api.security.ParteyApiAuthentication;
|
||||
import de.bstly.we.partey.businesslogic.ParteyMapManager;
|
||||
import de.bstly.we.partey.businesslogic.ParteyPermissions;
|
||||
import de.bstly.we.partey.businesslogic.ParteyUserTagManager;
|
||||
import de.bstly.we.partey.businesslogic.ParteyUserTexturesManager;
|
||||
import de.bstly.we.partey.businesslogic.model.Room;
|
||||
import de.bstly.we.partey.model.ParteyUserTag;
|
||||
import de.bstly.we.partey.model.ParteyUserTextures;
|
||||
|
||||
/**
|
||||
* The Class RoomController.
|
||||
@ -46,7 +50,11 @@ public class RoomController extends DebugLogger {
|
||||
@Autowired
|
||||
private ParteyUserTagManager parteyUserTagManager;
|
||||
@Autowired
|
||||
private ParteyUserTexturesManager parteyUserTexturesManager;
|
||||
@Autowired
|
||||
private UserManager userManager;
|
||||
@Autowired
|
||||
private WokaListManager wokaListManager;
|
||||
|
||||
@Value("${we.bstly.partey.visitCardUrlFormat:}")
|
||||
private String visitCardUrlFormat;
|
||||
@ -57,13 +65,16 @@ public class RoomController extends DebugLogger {
|
||||
* Access.
|
||||
*
|
||||
* @param userIdentifier the user identifier
|
||||
* @param roomId the room id
|
||||
* @param request the request
|
||||
* @param roomId the room id
|
||||
* @param characterLayers the character layers
|
||||
* @param ipAddress the ip address
|
||||
* @param request the request
|
||||
* @return the member data
|
||||
*/
|
||||
@GetMapping("/access")
|
||||
public MemberData access(@RequestParam("userIdentifier") String userIdentifier,
|
||||
@RequestParam("roomId") Optional<String> roomId,
|
||||
@RequestParam("characterLayers[]") Optional<String[]> characterLayers,
|
||||
@RequestParam("ipAddress") Optional<String> ipAddress, HttpServletRequest request) {
|
||||
parteyApiAuthentication.authenticateRequest(request);
|
||||
|
||||
@ -78,29 +89,81 @@ public class RoomController extends DebugLogger {
|
||||
}
|
||||
|
||||
MemberData memberData = new MemberData();
|
||||
memberData.setEmail("");
|
||||
memberData.setUserRoomToken("");
|
||||
memberData.setUserUuid(userIdentifier);
|
||||
memberData.setAnonymous(true);
|
||||
memberData.setTags(Lists.newArrayList());
|
||||
memberData.setTextures(Lists.newArrayList());
|
||||
boolean setTextures = false;
|
||||
User user = null;
|
||||
try {
|
||||
Long userId = Long.parseLong(userIdentifier);
|
||||
User user = userManager.get(userId);
|
||||
if (user != null && permissionManager.isFullUser(userId)
|
||||
&& permissionManager.hasPermission(userId, ParteyPermissions.PARTEY)) {
|
||||
user = userManager.get(userId);
|
||||
} catch (NumberFormatException e) {
|
||||
user = userManager.getByUsername(userIdentifier);
|
||||
if (user == null) {
|
||||
user = userManager.getByBstlyEmail(userIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(visitCardUrlFormat)) {
|
||||
memberData
|
||||
.setVisitCardUrl(String.format(visitCardUrlFormat, user.getUsername()));
|
||||
}
|
||||
if (user != null && permissionManager.isFullUser(user.getId())
|
||||
&& permissionManager.hasPermission(user.getId(), ParteyPermissions.PARTEY)) {
|
||||
|
||||
memberData.setAnonymous(false);
|
||||
ParteyUserTextures parteyUserTextures = parteyUserTexturesManager
|
||||
.getByTarget(user.getId());
|
||||
|
||||
for (ParteyUserTag parteyUserTag : parteyUserTagManager
|
||||
.getNonExpiredForUsername(user.getUsername())) {
|
||||
memberData.getTags().add(parteyUserTag.getTag());
|
||||
if (characterLayers.isPresent()) {
|
||||
if (parteyUserTextures == null) {
|
||||
parteyUserTextures = new ParteyUserTextures();
|
||||
parteyUserTextures.setTarget(user.getId());
|
||||
parteyUserTextures.setUsername(user.getUsername());
|
||||
parteyUserTextures.setTextures(Lists.newArrayList(characterLayers.get()));
|
||||
parteyUserTextures = parteyUserTexturesManager.save(parteyUserTextures);
|
||||
} else {
|
||||
if (parteyUserTextures.getTextures() == null) {
|
||||
parteyUserTextures.setTextures(Lists.newArrayList());
|
||||
}
|
||||
|
||||
if (parteyUserTextures.getTextures().size() != characterLayers.get().length
|
||||
|| !parteyUserTextures.getTextures()
|
||||
.containsAll(Lists.newArrayList(characterLayers.get()))) {
|
||||
parteyUserTextures.setTextures(Lists.newArrayList(characterLayers.get()));
|
||||
parteyUserTextures = parteyUserTexturesManager.save(parteyUserTextures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(visitCardUrlFormat)) {
|
||||
memberData.setVisitCardUrl(String.format(visitCardUrlFormat, user.getUsername()));
|
||||
}
|
||||
|
||||
memberData.setAnonymous(false);
|
||||
memberData.setEmail(userManager.getBstlyEmail(user.getUsername()));
|
||||
|
||||
if (parteyUserTextures != null && parteyUserTextures.getTextures() != null) {
|
||||
for (String layer : parteyUserTextures.getTextures()) {
|
||||
CharacterTexture characterTexture = wokaListManager.getCharacterTexture(layer);
|
||||
if (characterTexture != null) {
|
||||
memberData.getTextures().add(characterTexture);
|
||||
setTextures = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ParteyUserTag parteyUserTag : parteyUserTagManager
|
||||
.getNonExpiredForUsername(user.getUsername())) {
|
||||
memberData.getTags().add(parteyUserTag.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
if (!setTextures && characterLayers.isPresent()) {
|
||||
for (String layer : characterLayers.get()) {
|
||||
CharacterTexture characterTexture = wokaListManager.getCharacterTexture(layer);
|
||||
if (characterTexture != null) {
|
||||
memberData.getTextures().add(characterTexture);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
debugPrintResponse(request, Optional.of(memberData));
|
||||
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.api.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import de.bstly.we.partey.api.controller.model.WokaLayer;
|
||||
import de.bstly.we.partey.api.controller.support.DebugLogger;
|
||||
import de.bstly.we.partey.api.controller.support.WokaListManager;
|
||||
import de.bstly.we.partey.api.security.ParteyApiAuthentication;
|
||||
|
||||
/**
|
||||
* The Class WokaController.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/partey/api/woka")
|
||||
public class WokaController extends DebugLogger {
|
||||
|
||||
@Autowired
|
||||
private ParteyApiAuthentication parteyApiAuthentication;
|
||||
@Autowired
|
||||
private WokaListManager wokaListManager;
|
||||
|
||||
/**
|
||||
* Gets the woka list.
|
||||
*
|
||||
* @param roomUrl the room url
|
||||
* @param request the request
|
||||
* @return the woka list
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Map<String, WokaLayer> getWokaList(@RequestParam("roomUrl") String roomUrl,
|
||||
HttpServletRequest request) {
|
||||
parteyApiAuthentication.authenticateRequest(request);
|
||||
debugPrintRequest(request);
|
||||
|
||||
return wokaListManager.getWokaList();
|
||||
}
|
||||
|
||||
}
|
@ -8,17 +8,16 @@ package de.bstly.we.partey.api.controller.model;
|
||||
*/
|
||||
public class CharacterTexture {
|
||||
|
||||
private int id;
|
||||
private int level;
|
||||
private String id;
|
||||
private String url;
|
||||
private String rights;
|
||||
private String layer;
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -27,28 +26,10 @@ public class CharacterTexture {
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(int id) {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
*
|
||||
* @return the level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level.
|
||||
*
|
||||
* @param level the new level
|
||||
*/
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
@ -68,21 +49,21 @@ public class CharacterTexture {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rights.
|
||||
* Gets the layer.
|
||||
*
|
||||
* @return the rights
|
||||
* @return the layer
|
||||
*/
|
||||
public String getRights() {
|
||||
return rights;
|
||||
public String getLayer() {
|
||||
return layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rights.
|
||||
* Sets the layer.
|
||||
*
|
||||
* @param rights the new rights
|
||||
* @param layer the new layer
|
||||
*/
|
||||
public void setRights(String rights) {
|
||||
this.rights = rights;
|
||||
public void setLayer(String layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,48 +25,62 @@ public class MapDetailsData {
|
||||
private String iframeAuthentication;
|
||||
|
||||
/**
|
||||
* @return the roomSlug
|
||||
* Gets the room slug.
|
||||
*
|
||||
* @return the room slug
|
||||
*/
|
||||
public String getRoomSlug() {
|
||||
return roomSlug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roomSlug the roomSlug to set
|
||||
* Sets the room slug.
|
||||
*
|
||||
* @param roomSlug the new room slug
|
||||
*/
|
||||
public void setRoomSlug(String roomSlug) {
|
||||
this.roomSlug = roomSlug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mapUrl
|
||||
* Gets the map url.
|
||||
*
|
||||
* @return the map url
|
||||
*/
|
||||
public String getMapUrl() {
|
||||
return mapUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mapUrl the mapUrl to set
|
||||
* Sets the map url.
|
||||
*
|
||||
* @param mapUrl the new map url
|
||||
*/
|
||||
public void setMapUrl(String mapUrl) {
|
||||
this.mapUrl = mapUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the policy_type
|
||||
* Gets the policy type.
|
||||
*
|
||||
* @return the policy type
|
||||
*/
|
||||
public GameRoomPolicyTypes getPolicy_type() {
|
||||
return policy_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policy_type the policy_type to set
|
||||
* Sets the policy type.
|
||||
*
|
||||
* @param policy_type the new policy type
|
||||
*/
|
||||
public void setPolicy_type(GameRoomPolicyTypes policy_type) {
|
||||
this.policy_type = policy_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags.
|
||||
*
|
||||
* @return the tags
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
@ -74,13 +88,17 @@ public class MapDetailsData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tags the tags to set
|
||||
* Sets the tags.
|
||||
*
|
||||
* @param tags the new tags
|
||||
*/
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the textures.
|
||||
*
|
||||
* @return the textures
|
||||
*/
|
||||
public List<CharacterTexture> getTextures() {
|
||||
@ -88,41 +106,53 @@ public class MapDetailsData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textures the textures to set
|
||||
* Sets the textures.
|
||||
*
|
||||
* @param textures the new textures
|
||||
*/
|
||||
public void setTextures(List<CharacterTexture> textures) {
|
||||
this.textures = textures;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contactPage
|
||||
* Gets the contact page.
|
||||
*
|
||||
* @return the contact page
|
||||
*/
|
||||
public String getContactPage() {
|
||||
return contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contactPage the contactPage to set
|
||||
* Sets the contact page.
|
||||
*
|
||||
* @param contactPage the new contact page
|
||||
*/
|
||||
public void setContactPage(String contactPage) {
|
||||
this.contactPage = contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the authenticationMandatory
|
||||
* Checks if is authentication mandatory.
|
||||
*
|
||||
* @return true, if is authentication mandatory
|
||||
*/
|
||||
public boolean isAuthenticationMandatory() {
|
||||
return authenticationMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authenticationMandatory the authenticationMandatory to set
|
||||
* Sets the authentication mandatory.
|
||||
*
|
||||
* @param authenticationMandatory the new authentication mandatory
|
||||
*/
|
||||
public void setAuthenticationMandatory(boolean authenticationMandatory) {
|
||||
this.authenticationMandatory = authenticationMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group.
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public String getGroup() {
|
||||
@ -130,21 +160,27 @@ public class MapDetailsData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group the group to set
|
||||
* Sets the group.
|
||||
*
|
||||
* @param group the new group
|
||||
*/
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the iframeAuthentication
|
||||
* Gets the iframe authentication.
|
||||
*
|
||||
* @return the iframe authentication
|
||||
*/
|
||||
public String getIframeAuthentication() {
|
||||
return iframeAuthentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iframeAuthentication the iframeAuthentication to set
|
||||
* Sets the iframe authentication.
|
||||
*
|
||||
* @param iframeAuthentication the new iframe authentication
|
||||
*/
|
||||
public void setIframeAuthentication(String iframeAuthentication) {
|
||||
this.iframeAuthentication = iframeAuthentication;
|
||||
|
@ -12,12 +12,32 @@ import com.beust.jcommander.internal.Lists;
|
||||
*/
|
||||
public class MemberData {
|
||||
|
||||
private String email;
|
||||
private String userUuid;
|
||||
private List<String> tags = Lists.newArrayList();
|
||||
private String visitCardUrl;
|
||||
private List<CharacterTexture> textures = Lists.newArrayList();
|
||||
private List<Object> messages = Lists.newArrayList();
|
||||
private boolean anonymous;
|
||||
private String userRoomToken;
|
||||
|
||||
/**
|
||||
* Gets the email.
|
||||
*
|
||||
* @return the email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the email.
|
||||
*
|
||||
* @param email the new email
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user uuid.
|
||||
@ -127,4 +147,22 @@ public class MemberData {
|
||||
this.anonymous = anonymous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user room token.
|
||||
*
|
||||
* @return the user room token
|
||||
*/
|
||||
public String getUserRoomToken() {
|
||||
return userRoomToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user room token.
|
||||
*
|
||||
* @param userRoomToken the new user room token
|
||||
*/
|
||||
public void setUserRoomToken(String userRoomToken) {
|
||||
this.userRoomToken = userRoomToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.api.controller.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class WokaCollection.
|
||||
*/
|
||||
public class WokaCollection {
|
||||
|
||||
private String name;
|
||||
private int position;
|
||||
private List<WokaTexture> textures;
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the position.
|
||||
*
|
||||
* @return the position
|
||||
*/
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position.
|
||||
*
|
||||
* @param position the new position
|
||||
*/
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the textures.
|
||||
*
|
||||
* @return the textures
|
||||
*/
|
||||
public List<WokaTexture> getTextures() {
|
||||
return textures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the textures.
|
||||
*
|
||||
* @param textures the new textures
|
||||
*/
|
||||
public void setTextures(List<WokaTexture> textures) {
|
||||
this.textures = textures;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.api.controller.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class WokaLayer.
|
||||
*/
|
||||
public class WokaLayer {
|
||||
|
||||
private boolean required;
|
||||
private List<WokaCollection> collections;
|
||||
|
||||
/**
|
||||
* Checks if is required.
|
||||
*
|
||||
* @return true, if is required
|
||||
*/
|
||||
public boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the required.
|
||||
*
|
||||
* @param required the new required
|
||||
*/
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collections.
|
||||
*
|
||||
* @return the collections
|
||||
*/
|
||||
public List<WokaCollection> getCollections() {
|
||||
return collections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the collections.
|
||||
*
|
||||
* @param collections the new collections
|
||||
*/
|
||||
public void setCollections(List<WokaCollection> collections) {
|
||||
this.collections = collections;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.api.controller.model;
|
||||
|
||||
/**
|
||||
* The Class WokaTexture.
|
||||
*/
|
||||
public class WokaTexture {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String url;
|
||||
private int position;
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url.
|
||||
*
|
||||
* @param url the new url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the position.
|
||||
*
|
||||
* @return the position
|
||||
*/
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position.
|
||||
*
|
||||
* @param position the new position
|
||||
*/
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
@ -37,21 +37,31 @@ public class DebugLogger {
|
||||
* @param payload the payload
|
||||
*/
|
||||
public void debugPrintRequest(HttpServletRequest request, Optional<Object> payload) {
|
||||
logger.debug(
|
||||
"Request: " + request.getMethod().toUpperCase() + " " + request.getRequestURI());
|
||||
logger.debug("Request: "
|
||||
+ request.getMethod().toUpperCase()
|
||||
+ " "
|
||||
+ request.getRequestURI());
|
||||
|
||||
logger.debug("Headers:");
|
||||
|
||||
for (Iterator<String> it = request.getHeaderNames().asIterator(); it.hasNext();) {
|
||||
String headerName = it.next();
|
||||
logger.debug("\t" + headerName + ": " + request.getHeader(headerName));
|
||||
logger.debug("\t"
|
||||
+ headerName
|
||||
+ ": "
|
||||
+ request.getHeader(headerName));
|
||||
}
|
||||
|
||||
if (!request.getParameterMap().isEmpty()) {
|
||||
logger.debug("Parameters:");
|
||||
for (Iterator<String> it = request.getParameterNames().asIterator(); it.hasNext();) {
|
||||
String parameterName = it.next();
|
||||
logger.debug("\t" + parameterName + ": " + request.getParameter(parameterName));
|
||||
for (String value : request.getParameterValues(parameterName)) {
|
||||
logger.debug("\t"
|
||||
+ parameterName
|
||||
+ ": "
|
||||
+ value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +81,8 @@ public class DebugLogger {
|
||||
*/
|
||||
public void debugPrintResponse(HttpServletRequest response, Optional<Object> payload) {
|
||||
if (payload.isPresent()) {
|
||||
logger.debug("Response: " + response.getRequestURI());
|
||||
logger.debug("Response: "
|
||||
+ response.getRequestURI());
|
||||
logger.debug("Body:");
|
||||
logger.debug(gson.toJson(payload.get()));
|
||||
logger.debug("");
|
||||
|
@ -0,0 +1,105 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.api.controller.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import de.bstly.we.businesslogic.SystemPropertyManager;
|
||||
import de.bstly.we.partey.api.controller.model.CharacterTexture;
|
||||
import de.bstly.we.partey.api.controller.model.WokaCollection;
|
||||
import de.bstly.we.partey.api.controller.model.WokaLayer;
|
||||
import de.bstly.we.partey.api.controller.model.WokaTexture;
|
||||
|
||||
/**
|
||||
* The Class WokaListManager.
|
||||
*/
|
||||
@Component
|
||||
public class WokaListManager implements SmartInitializingSingleton {
|
||||
|
||||
@Autowired
|
||||
private SystemPropertyManager systemPropertyManager;
|
||||
@Autowired
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
private Map<String, WokaLayer> wokaList = Maps.newHashMap();
|
||||
Type wokaListType = new TypeToken<Map<String, WokaLayer>>() {
|
||||
}.getType();
|
||||
|
||||
/*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
|
||||
*/
|
||||
/*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#
|
||||
* afterSingletonsInstantiated()
|
||||
*/
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
if (!systemPropertyManager.has("partey.woka.list")) {
|
||||
try {
|
||||
Resource resource = resourceLoader.getResource("classpath:woka.json");
|
||||
|
||||
if (resource.exists()) {
|
||||
wokaList = gson.fromJson(new InputStreamReader(resource.getInputStream()),
|
||||
wokaListType);
|
||||
systemPropertyManager.add("partey.woka.list", gson.toJson(wokaList));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
wokaList = gson.fromJson(systemPropertyManager.get("partey.woka.list"), wokaListType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the woka list.
|
||||
*
|
||||
* @return the woka list
|
||||
*/
|
||||
public Map<String, WokaLayer> getWokaList() {
|
||||
return wokaList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the character texture.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the character texture
|
||||
*/
|
||||
public CharacterTexture getCharacterTexture(String id) {
|
||||
CharacterTexture characterTexture = new CharacterTexture();
|
||||
|
||||
for (Entry<String, WokaLayer> entry : wokaList.entrySet()) {
|
||||
for (WokaCollection wokaCollection : entry.getValue().getCollections()) {
|
||||
for (WokaTexture wokaTexture : wokaCollection.getTextures()) {
|
||||
if (wokaTexture.getId().equals(id)) {
|
||||
characterTexture.setId(id);
|
||||
characterTexture.setLayer(entry.getKey());
|
||||
characterTexture.setUrl(wokaTexture.getUrl());
|
||||
return characterTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.businesslogic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.bstly.we.businesslogic.UserDataProvider;
|
||||
import de.bstly.we.model.UserData;
|
||||
import de.bstly.we.partey.model.ParteyUserTextures;
|
||||
import de.bstly.we.partey.model.QParteyUserTextures;
|
||||
import de.bstly.we.partey.repository.ParteyUserTexturesRepository;
|
||||
|
||||
/**
|
||||
* The Class ParteyUserTexturesManager.
|
||||
*/
|
||||
@Component
|
||||
public class ParteyUserTexturesManager implements UserDataProvider {
|
||||
|
||||
@Autowired
|
||||
private ParteyUserTexturesRepository parteyUserTexturesRepository;
|
||||
private QParteyUserTextures qParteyUserTextures = QParteyUserTextures.parteyUserTextures;
|
||||
|
||||
/**
|
||||
* Gets the all.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the all
|
||||
*/
|
||||
public Page<ParteyUserTextures> getAll(int page, int size, String sortBy, boolean descending) {
|
||||
PageRequest pageRequest = PageRequest.of(page, size,
|
||||
descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending());
|
||||
|
||||
return parteyUserTexturesRepository.findAll(pageRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by target.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @return the by target
|
||||
*/
|
||||
public ParteyUserTextures getByTarget(Long userId) {
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.target.eq(userId))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by username.
|
||||
*
|
||||
* @param username the username
|
||||
* @return the by username
|
||||
*/
|
||||
public ParteyUserTextures getByUsername(String username) {
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.username.eq(username))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save.
|
||||
*
|
||||
* @param parteyUserTextures the partey user textures
|
||||
* @return the partey user textures
|
||||
*/
|
||||
public ParteyUserTextures save(ParteyUserTextures parteyUserTextures) {
|
||||
return parteyUserTexturesRepository.save(parteyUserTextures);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param parteyUserTag the partey user tag
|
||||
*/
|
||||
public void delete(ParteyUserTextures parteyUserTag) {
|
||||
if (parteyUserTag != null) {
|
||||
parteyUserTexturesRepository.delete(parteyUserTag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete by target.
|
||||
*
|
||||
* @param target the target
|
||||
*/
|
||||
public void deleteByTarget(Long target) {
|
||||
delete(getByTarget(target));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "partey-textures";
|
||||
}
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public List<UserData> getUserData(Long userId) {
|
||||
List<UserData> result = Lists.newArrayList(getByTarget(userId));
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public void purgeUserData(Long userId) {
|
||||
deleteByTarget(userId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.bstly.we.model.UserData;
|
||||
|
||||
/**
|
||||
* The Class ParteyUserTextures.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "partey_user_textures")
|
||||
public class ParteyUserTextures implements UserData {
|
||||
|
||||
@Id
|
||||
private Long target;
|
||||
@Column(name = "username", nullable = false)
|
||||
private String username;
|
||||
@ElementCollection
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
@CollectionTable(name = "partey_user_textures_list")
|
||||
private List<String> textures = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Gets the target.
|
||||
*
|
||||
* @return the target
|
||||
*/
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target.
|
||||
*
|
||||
* @param target the new target
|
||||
*/
|
||||
public void setTarget(Long target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username.
|
||||
*
|
||||
* @param username the new username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the textures.
|
||||
*
|
||||
* @return the textures
|
||||
*/
|
||||
public List<String> getTextures() {
|
||||
return textures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the textures.
|
||||
*
|
||||
* @param textures the new textures
|
||||
*/
|
||||
public void setTextures(List<String> textures) {
|
||||
this.textures = textures;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.we.partey.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.bstly.we.partey.model.ParteyUserTextures;
|
||||
|
||||
/**
|
||||
* The Interface ParteyUserTexturesRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface ParteyUserTexturesRepository extends JpaRepository<ParteyUserTextures, Long>,
|
||||
QuerydslPredicateExecutor<ParteyUserTextures> {
|
||||
}
|
@ -57,15 +57,15 @@ public class TimeslotController extends BaseController {
|
||||
/**
|
||||
* Gets the timeslots.
|
||||
*
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param visibilityParameter the visibility parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @return the timeslots
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
|
@ -61,7 +61,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate time.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTime(Timeslot timeslot, Errors errors) {
|
||||
if (timeslot.getStarts() == null) {
|
||||
@ -136,7 +136,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate type.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateType(Timeslot timeslot, Errors errors) {
|
||||
if (timeslot.getId() != null && timeslotRepository.existsById(timeslot.getId())) {
|
||||
@ -162,10 +162,10 @@ public class TimeslotValidator implements Validator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate type audio.
|
||||
* Validate share.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateShare(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setStream(null);
|
||||
@ -177,10 +177,10 @@ public class TimeslotValidator implements Validator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate type audio.
|
||||
* Validate type audio stream.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTypeAudioStream(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setStream(null);
|
||||
@ -196,10 +196,10 @@ public class TimeslotValidator implements Validator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate type video.
|
||||
* Validate type video stream.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTypeVideoStream(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setSecret(null);
|
||||
|
@ -202,6 +202,8 @@ public class Timeslot implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the share.
|
||||
*
|
||||
* @return the share
|
||||
*/
|
||||
public String getShare() {
|
||||
@ -209,7 +211,9 @@ public class Timeslot implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param share the share to set
|
||||
* Sets the share.
|
||||
*
|
||||
* @param share the new share
|
||||
*/
|
||||
public void setShare(String share) {
|
||||
this.share = share;
|
||||
|
Loading…
Reference in New Issue
Block a user