-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3627 File permissions checked and applied
- Loading branch information
Showing
4 changed files
with
109 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
opal-core-ws/src/main/java/org/obiba/opal/web/provider/ForbiddenExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2021 OBiBa. All rights reserved. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the GNU Public License v3.0. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.obiba.opal.web.provider; | ||
|
||
import com.google.protobuf.GeneratedMessage; | ||
import org.obiba.opal.web.magma.ClientErrorDtos; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.ws.rs.ForbiddenException; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import static javax.ws.rs.core.Response.Status.FORBIDDEN; | ||
|
||
@Component | ||
@Provider | ||
public class ForbiddenExceptionMapper extends ErrorDtoExceptionMapper<ForbiddenException> { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ForbiddenExceptionMapper.class); | ||
|
||
@Override | ||
protected Response.Status getStatus() { | ||
return FORBIDDEN; | ||
} | ||
|
||
@Override | ||
protected GeneratedMessage.ExtendableMessage<?> getErrorDto(ForbiddenException exception) { | ||
log.warn("Forbidden exception", exception); | ||
return ClientErrorDtos.getErrorMessage(getStatus(), "Forbidden", exception); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters