Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prefix check before update properties
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...src/main/java/org/fcrepo/http/commons/exceptionhandlers/InvalidPrefixExceptionMapper.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,47 @@ | ||
/** | ||
* Copyright 2015 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.fcrepo.http.commons.exceptionhandlers; | ||
|
||
import static javax.ws.rs.core.Response.status; | ||
import static javax.ws.rs.core.Response.Status.BAD_REQUEST; | ||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import org.fcrepo.kernel.api.exception.InvalidPrefixException; | ||
|
||
import org.slf4j.Logger; | ||
|
||
/** | ||
* For invalid namespace exceptions on CRUD actions for nodes/datastreams | ||
* | ||
* @author nianma | ||
* @since November 2, 2015 | ||
*/ | ||
@Provider | ||
public class InvalidPrefixExceptionMapper implements ExceptionMapper<InvalidPrefixException> { | ||
|
||
private static final Logger LOGGER = getLogger(InvalidPrefixExceptionMapper.class); | ||
|
||
@Override | ||
public Response toResponse(final InvalidPrefixException e) { | ||
LOGGER.trace("FedoraInvalidPrefixExceptionMapper caught an exception: {}", e.getMessage()); | ||
return status(BAD_REQUEST).entity(e.getMessage()).build(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
fcrepo-kernel-api/src/main/java/org/fcrepo/kernel/api/exception/InvalidPrefixException.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,48 @@ | ||
/** | ||
* Copyright 2015 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.fcrepo.kernel.api.exception; | ||
|
||
|
||
/** | ||
* Indicates a prefix used in a CRUD request has existed in the repository | ||
* | ||
* @author nianma | ||
* @since Nov 2, 2015 | ||
*/ | ||
public class InvalidPrefixException extends RepositoryRuntimeException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* Ordinary constructor | ||
* | ||
* @param msg the message | ||
*/ | ||
public InvalidPrefixException(final String msg) { | ||
super(msg); | ||
} | ||
|
||
/** | ||
* Ordinary constructor | ||
* | ||
* @param msg the message | ||
* @param rootCause the root cause | ||
*/ | ||
public InvalidPrefixException(final String msg, final Throwable rootCause) { | ||
super(msg, rootCause); | ||
} | ||
|
||
} |
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