Directory integration prototype using Google Firebase auth + Synapse SQL
This commit is contained in:
@@ -18,10 +18,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.kamax.mxisd.controller.identity.v1;
|
||||
package io.kamax.mxisd.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import io.kamax.mxisd.exception.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -72,7 +73,7 @@ public class DefaultExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public String handle(MissingServletRequestParameterException e) {
|
||||
return handle("M_INVALID_BODY", e.getMessage());
|
||||
return handle("M_INCOMPLETE_REQUEST", e.getMessage());
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@@ -81,6 +82,12 @@ public class DefaultExceptionHandler {
|
||||
return handle("M_INVALID_JSON", e.getMessage());
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(JsonSyntaxException.class)
|
||||
public String handle(JsonSyntaxException e) {
|
||||
return handle("M_INVALID_JSON", e.getMessage());
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(JsonMemberNotFoundException.class)
|
||||
public String handle(JsonMemberNotFoundException e) {
|
||||
@@ -107,7 +114,7 @@ public class DefaultExceptionHandler {
|
||||
"M_UNKNOWN",
|
||||
StringUtils.defaultIfBlank(
|
||||
e.getMessage(),
|
||||
"An internal server error occured. If this error persists, please contact support with reference #" +
|
||||
"An internal server error occurred. If this error persists, please contact support with reference #" +
|
||||
Instant.now().toEpochMilli()
|
||||
)
|
||||
);
|
||||
@@ -28,10 +28,7 @@ import io.kamax.mxisd.util.GsonParser;
|
||||
import io.kamax.mxisd.util.GsonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
@@ -48,7 +45,7 @@ public class UserDirectoryController {
|
||||
@Autowired
|
||||
private DirectoryManager mgr;
|
||||
|
||||
@RequestMapping(path = "/search")
|
||||
@RequestMapping(path = "/search", method = RequestMethod.POST)
|
||||
public String search(HttpServletRequest request, @RequestParam("access_token") String accessToken) throws IOException {
|
||||
UserDirectorySearchRequest searchQuery = parser.parse(request, UserDirectorySearchRequest.class);
|
||||
URI target = URI.create(request.getRequestURL().toString());
|
||||
|
||||
@@ -24,6 +24,10 @@ public class UserDirectorySearchRequest {
|
||||
|
||||
private String searchTerm;
|
||||
|
||||
public UserDirectorySearchRequest(String searchTerm) {
|
||||
setSearchTerm(searchTerm);
|
||||
}
|
||||
|
||||
public String getSearchTerm() {
|
||||
return searchTerm;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user