Package com.ubs.backend.services
Class AdminTool
java.lang.Object
com.ubs.backend.services.AdminTool
Services for the AdminTool
- Since:
- 17.07.2021
- Author:
- Marc Andri Fuchs, Magnus Goetz, Tim Irmler, Sarah
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavax.ws.rs.core.ResponseaddAnswer(String title, String ans, String tagsString, boolean isHidden, int answerTypeOrdinal, String files, javax.servlet.http.HttpServletRequest request)service to add an answer to the DBjavax.ws.rs.core.ResponseaddBlacklistEntry(String content, javax.servlet.http.HttpServletRequest request)Service to add a BlacklistEntry to the Databasejavax.ws.rs.core.ResponseaddQuestion(String defaultQuestionString, javax.servlet.http.HttpServletRequest request)Service to add a defaultquestion to the Databasejavax.ws.rs.core.ResponseService to create a Tagprivate voidaddTypeTag(AnswerType type, Tag tag, List<TypeTag> typeTags, TypeTagDAO typeTagDAO, javax.persistence.EntityManager em)method to add tag to type tags if tag doesn't already exist with this typejavax.ws.rs.core.ResponseblacklistMatch(String sId, javax.servlet.http.HttpServletRequest request)Service to blacklist a word from a MatchchangePassword(String oldPass, String newPass, javax.servlet.http.HttpServletRequest request)Service to change the Password of a UserLoginjavax.ws.rs.core.ResponsecheckLogin(javax.servlet.http.HttpServletRequest request)Service to check if a User is logged injavax.ws.rs.core.ResponsedeleteAnswer(long answerID, javax.servlet.http.HttpServletRequest request)Service to delete an Answer from the Database.javax.ws.rs.core.ResponsedeleteAnsweredQuestion(long questionID, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.ResponsedeleteBlacklistEntry(String entryId, javax.servlet.http.HttpServletRequest request)Service to delete a BlacklistEntry from the Databasejavax.ws.rs.core.ResponsedeleteFile(String file, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.ResponsedeleteQuestion(String questionId, javax.servlet.http.HttpServletRequest request)Service to delete defaultQuestionjavax.ws.rs.core.ResponseService to delete a tagjavax.ws.rs.core.ResponsedeleteUnansweredQuestion(long questionID, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.ResponsedeleteUser(long userId, javax.servlet.http.HttpServletRequest request)Service to delete a UserLogin from the Databasejavax.ws.rs.core.ResponseeditAnsweredQuestion(long questionID, String question, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.ResponseeditBlacklistEntry(String entryId, String content, javax.servlet.http.HttpServletRequest request)Service to edit a Blacklist entryjavax.ws.rs.core.ResponseeditQuestion(long answerId, String title, String ans, String tagsString, boolean isHidden, int answerTypeOrdinal, String files, javax.servlet.http.HttpServletRequest request)service to edit an already existing answerjavax.ws.rs.core.ResponseeditQuestion(long defaultQuestionId, String defaultQuestion, javax.servlet.http.HttpServletRequest request)Service to edit a default questionjavax.ws.rs.core.ResponseService to edit a Tagjavax.ws.rs.core.ResponseeditUser(long userId, String email, int canCreateUser, javax.servlet.http.HttpServletRequest request)Service to edit userprivate booleanexistsTagAlreadyInArray(String tagToFind, List<Tag> tags)method to check if a tag already exists in the answer resultgetTagsFromString(String tagsString, String splitter, javax.persistence.EntityManager em)method to get all tags from a string.javax.ws.rs.core.ResponsenoTranslate(long matchID, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.ResponseremoveFileFromAnswer(long answerId, long fileId, javax.servlet.http.HttpServletRequest request)Webservice to remove a File from an Answerjavax.ws.rs.core.ResponseremoveTagFromAnswer(long answerId, long tagId, javax.servlet.http.HttpServletRequest request)Service to remove a tag from an answer in the databasejavax.ws.rs.core.ResponseresetMatchRating(long id, javax.servlet.http.HttpServletRequest request)private voidsetAnswerFiles(String files, javax.persistence.EntityManager em, Answer answer)private javax.ws.rs.core.ResponseuserIsLoggedIn(javax.servlet.http.HttpServletRequest request)Method to check if the user is logged in
-
Constructor Details
-
AdminTool
public AdminTool()
-
-
Method Details
-
addAnswer
@Path("/addAnswer") @POST @Produces("application/json") public javax.ws.rs.core.Response addAnswer(@FormParam("aTitle") String title, @FormParam("aText") String ans, @FormParam("tags") String tagsString, @FormParam("isHidden") boolean isHidden, @FormParam("answerTypeOrdinal") int answerTypeOrdinal, @FormParam("files") String files, @Context javax.servlet.http.HttpServletRequest request)service to add an answer to the DB- Parameters:
title- the title of the answerans- the answertagsString- all the tags as a simple string, seperated with a commaisHidden- if the answer is hidden or notanswerTypeOrdinal- the ordinal value of the answerTypefiles-request- the HTTP request- Returns:
- status
- Since:
- 17.07.2021
-
setAnswerFiles
-
editQuestion
@Path("/editAnswer") @POST @Produces("text/plain") public javax.ws.rs.core.Response editQuestion(@FormParam("answerId") long answerId, @FormParam("aTitle") String title, @FormParam("aText") String ans, @FormParam("newTags") String tagsString, @FormParam("isHidden") boolean isHidden, @FormParam("answerTypeOrdinal") int answerTypeOrdinal, @FormParam("files") String files, @Context javax.servlet.http.HttpServletRequest request)service to edit an already existing answer- Parameters:
answerId- the id of the answertitle- the title of the answerans- the answertagsString- the new tags to add, as a simple string seperated by a commaisHidden- if the answer is hidden or notanswerTypeOrdinal- the ordinal value of the answerTypefiles-request- the HTTP request- Returns:
- status
- Since:
- 17.07.2021
-
removeFileFromAnswer
@Path("/removeFileFromAnswer") @POST @Produces("text/plain") public javax.ws.rs.core.Response removeFileFromAnswer(@FormParam("answerId") long answerId, @FormParam("fileId") long fileId, @Context javax.servlet.http.HttpServletRequest request)Webservice to remove a File from an Answer- Parameters:
answerId- the ID of theAnswerwhich theUploadFilewill be remove fromfileId- the ID of theUploadFilerequest-- Returns:
-
removeTagFromAnswer
@Path("/removeTagFromAnswer") @POST @Produces("text/plain") public javax.ws.rs.core.Response removeTagFromAnswer(@FormParam("answerId") long answerId, @FormParam("tagId") long tagId, @Context javax.servlet.http.HttpServletRequest request)Service to remove a tag from an answer in the database- Parameters:
answerId- the Answer, where the Tag should be removedtagId- the Tag that should be removedrequest- the HttpRequest- Returns:
- Status 200 if succeeded else 502
- Since:
- 17.07.2021
-
addTag
@Path("/addTag") @POST @Produces("text/plain") public javax.ws.rs.core.Response addTag(@FormParam("tag") String tag, @Context javax.servlet.http.HttpServletRequest request)Service to create a Tag- Parameters:
tag- the Text that should be converted to a Tagrequest- the HttpRequest- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 17.07.2021
-
editTag
@Path("/editTag") @POST @Produces("text/plain") public javax.ws.rs.core.Response editTag(@FormParam("tagID") String tagIDs, @FormParam("tagContent") String tagContent, @Context javax.servlet.http.HttpServletRequest request)Service to edit a Tag- Parameters:
tagIDs- the ID of the Tag which is going to be editedtagContent- the new Content of the Tagrequest- the HttpRequest- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 17.07.2021
-
deleteTag
@Path("/deleteTag") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteTag(@FormParam("tagID") String tag, @Context javax.servlet.http.HttpServletRequest request)Service to delete a tag- Parameters:
tag- the ID of the Tag to deleterequest- the HttpRequest- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 17.07.2021
-
deleteAnswer
@Path("/deleteAnswer") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteAnswer(@FormParam("answerID") long answerID, @Context javax.servlet.http.HttpServletRequest request)Service to delete an Answer from the Database.- Parameters:
answerID- the ID of the Answer which should be deletedrequest- the HttpRequest- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 17.07.2021
-
editAnsweredQuestion
@Path("/editAnsweredQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response editAnsweredQuestion(@FormParam("questionID") long questionID, @FormParam("question") String question, @Context javax.servlet.http.HttpServletRequest request) -
deleteAnsweredQuestion
@Path("/deleteAnsweredQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteAnsweredQuestion(@FormParam("questionID") long questionID, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
questionID-request-- Returns:
- Since:
- 19.08.2021
-
deleteUnansweredQuestion
@Path("/deleteUnansweredQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteUnansweredQuestion(@FormParam("questionID") long questionID, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
questionID-request-- Returns:
- Since:
- 19.08.2021
-
changePassword
@Path("/changePassword") @POST @Produces("text/plain") public String changePassword(@FormParam("oldPass") String oldPass, @FormParam("newPass") String newPass, @Context javax.servlet.http.HttpServletRequest request)Service to change the Password of a UserLogin- Parameters:
oldPass- the Password to changenewPass- the new Passwordrequest- the HttpRequest- Returns:
- Status 200 if succeeded | 403 if failed
- Since:
- 17.07.2021
-
deleteFile
@Path("/removeFile") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteFile(@FormParam("fileID") String file, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
file-request-- Returns:
- Since:
- 17.07.2021
-
existsTagAlreadyInArray
method to check if a tag already exists in the answer result- Parameters:
tagToFind- the tag we want to check if it already exists or nottags- the array in which we want to check- Returns:
- returns true if the tag already exists, returns false otherwise
- Since:
- 17.07.2021
-
getTagsFromString
private ArrayList<Tag> getTagsFromString(String tagsString, String splitter, javax.persistence.EntityManager em)method to get all tags from a string. if the tag already exists in the DB, use this tag. if not, create a new one.- Parameters:
tagsString- the string with all the tagssplitter- defines how the tags are seperated in the stringem- the entity manager- Returns:
- returns an array of all tags
- Since:
- 17.07.2021
-
addTypeTag
private void addTypeTag(AnswerType type, Tag tag, List<TypeTag> typeTags, TypeTagDAO typeTagDAO, javax.persistence.EntityManager em)method to add tag to type tags if tag doesn't already exist with this type- Parameters:
type- the type of the tagtag- the tagtypeTags- all the type tags to checktypeTagDAO- the type tag daoem- the entity manager- Since:
- 17.07.2021
-
addQuestion
@Path("/addQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response addQuestion(@FormParam("defaultQuestion") String defaultQuestionString, @Context javax.servlet.http.HttpServletRequest request)Service to add a defaultquestion to the Database- Parameters:
defaultQuestionString- the defaultquestionrequest- the http request- Returns:
- status 200
- Since:
- 17.07.2021
-
editQuestion
@Path("/editQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response editQuestion(@FormParam("defaultQuestionId") long defaultQuestionId, @FormParam("defaultQuestion") String defaultQuestion, @Context javax.servlet.http.HttpServletRequest request)Service to edit a default question- Parameters:
defaultQuestionId- the ID of the default questiondefaultQuestion- the default questionrequest- the HTTP request- Returns:
- status
- Since:
- 17.07.2021
-
deleteQuestion
@Path("/deleteQuestion") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteQuestion(@FormParam("questionId") String questionId, @Context javax.servlet.http.HttpServletRequest request)Service to delete defaultQuestion- Parameters:
questionId- the id of the defaultQuestion to deleterequest- the HttpRequest- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 25.08.2021
-
editBlacklistEntry
@Path("/editBlacklistEntry") @POST @Produces("text/plain") public javax.ws.rs.core.Response editBlacklistEntry(@FormParam("entryId") String entryId, @FormParam("content") String content, @Context javax.servlet.http.HttpServletRequest request)Service to edit a Blacklist entry- Parameters:
entryId- the id of the Entry which is going to be editedcontent- the new content for the BlacklistEntryrequest-- Returns:
- if it worked
- See Also:
BlacklistEntry
-
addBlacklistEntry
@Path("/addBlacklistEntry") @POST @Produces("text/plain") public javax.ws.rs.core.Response addBlacklistEntry(@FormParam("content") String content, @Context javax.servlet.http.HttpServletRequest request)Service to add a BlacklistEntry to the Database- Parameters:
content- the Word which will be blacklistedrequest-- Returns:
- the newly created BlacklistEntry
- Since:
- 22.07.2021
- See Also:
BlacklistEntry
-
deleteBlacklistEntry
@Path("/deleteBlacklistEntry") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteBlacklistEntry(@FormParam("entryId") String entryId, @Context javax.servlet.http.HttpServletRequest request)Service to delete a BlacklistEntry from the Database- Parameters:
entryId- the ID of the BlacklistEntryrequest-- Returns:
- if it worked
- See Also:
BlacklistEntry
-
userIsLoggedIn
private javax.ws.rs.core.Response userIsLoggedIn(javax.servlet.http.HttpServletRequest request)Method to check if the user is logged in- Parameters:
request- the Request of the User- Returns:
- null if the user is logged in, else a Response with the HTTP Code 403
-
checkLogin
@Path("/checkLogin") @POST @Produces("application/json") public javax.ws.rs.core.Response checkLogin(@Context javax.servlet.http.HttpServletRequest request)Service to check if a User is logged in- Parameters:
request- the request of the User- Returns:
- a json object containing if the User is logged in
-
blacklistMatch
@Path("/blacklistMatch") @POST @Produces("application/json") public javax.ws.rs.core.Response blacklistMatch(@FormParam("matchId") String sId, @Context javax.servlet.http.HttpServletRequest request)Service to blacklist a word from a Match- Parameters:
sId- the Id of the Matchrequest- the request of the User- Returns:
- a json Object if it worked
- See Also:
BlacklistEntry,Match
-
resetMatchRating
@Path("resetMatchRating") @POST @Produces("application/json") public javax.ws.rs.core.Response resetMatchRating(@FormParam("matchID") long id, @Context javax.servlet.http.HttpServletRequest request) -
deleteUser
@Path("/deleteUser") @POST @Produces("text/plain") public javax.ws.rs.core.Response deleteUser(@FormParam("userId") long userId, @Context javax.servlet.http.HttpServletRequest request)Service to delete a UserLogin from the Database- Parameters:
userId- the ID of the UserLoginrequest- the HTTP request- Returns:
- Status 200 if succeeded | 502 if failed
- Since:
- 02.08.2021
-
editUser
@Path("/editUser") @POST @Produces("text/plain") public javax.ws.rs.core.Response editUser(@FormParam("userId") long userId, @FormParam("email") String email, @FormParam("canCreateUser") int canCreateUser, @Context javax.servlet.http.HttpServletRequest request)Service to edit user- Parameters:
userId- the ID of the useremail- the eamil of the usercanCreateUser- if it can create userrequest- the HTTP request- Returns:
- status
- Since:
- 03.08.2021
-
noTranslate
@Path("/noTranslate") @POST @Produces("text/plain") public javax.ws.rs.core.Response noTranslate(@FormParam("matchID") long matchID, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
matchID-request-- Returns:
- Since:
- 14.08.2021
-