forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/coar-notify-7' into coar-notify-7
- Loading branch information
Showing
20 changed files
with
643 additions
and
7 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
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
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
15 changes: 15 additions & 0 deletions
15
...e/storage/rdbms/sqlmigration/h2/V8.0_2024.01.12__notifyservice_table_ip_range_coulmns.sql
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,15 @@ | ||
-- | ||
-- The contents of this file are subject to the license and copyright | ||
-- detailed in the LICENSE and NOTICE files at the root of the source | ||
-- tree and available online at | ||
-- | ||
-- http://www.dspace.org/license/ | ||
-- | ||
|
||
-------------------------------------------------------------------------- | ||
-- ADD IP Range columns to notifyservice table | ||
-------------------------------------------------------------------------- | ||
|
||
ALTER TABLE notifyservice ADD COLUMN lower_ip VARCHAR(45); | ||
|
||
ALTER TABLE notifyservice ADD COLUMN upper_ip VARCHAR(45); |
13 changes: 13 additions & 0 deletions
13
...ace/storage/rdbms/sqlmigration/h2/V8.0_2024.01.13__ldn_message_table_source_ip_coulmn.sql
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,13 @@ | ||
-- | ||
-- The contents of this file are subject to the license and copyright | ||
-- detailed in the LICENSE and NOTICE files at the root of the source | ||
-- tree and available online at | ||
-- | ||
-- http://www.dspace.org/license/ | ||
-- | ||
|
||
-------------------------------------------------------------------------- | ||
-- ADD source_ip columns to ldn_message table | ||
-------------------------------------------------------------------------- | ||
|
||
ALTER TABLE ldn_message ADD COLUMN source_ip VARCHAR(45); |
15 changes: 15 additions & 0 deletions
15
...age/rdbms/sqlmigration/postgres/V8.0_2024.01.12__notifyservice_table_ip_range_coulmns.sql
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,15 @@ | ||
-- | ||
-- The contents of this file are subject to the license and copyright | ||
-- detailed in the LICENSE and NOTICE files at the root of the source | ||
-- tree and available online at | ||
-- | ||
-- http://www.dspace.org/license/ | ||
-- | ||
|
||
-------------------------------------------------------------------------- | ||
-- ADD IP Range columns to notifyservice table | ||
-------------------------------------------------------------------------- | ||
|
||
ALTER TABLE notifyservice ADD COLUMN lower_ip VARCHAR(45); | ||
|
||
ALTER TABLE notifyservice ADD COLUMN upper_ip VARCHAR(45); |
13 changes: 13 additions & 0 deletions
13
...orage/rdbms/sqlmigration/postgres/V8.0_2024.01.13__ldn_message_table_source_ip_coulmn.sql
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,13 @@ | ||
-- | ||
-- The contents of this file are subject to the license and copyright | ||
-- detailed in the LICENSE and NOTICE files at the root of the source | ||
-- tree and available online at | ||
-- | ||
-- http://www.dspace.org/license/ | ||
-- | ||
|
||
-------------------------------------------------------------------------- | ||
-- ADD source_ip columns to ldn_message table | ||
-------------------------------------------------------------------------- | ||
|
||
ALTER TABLE ldn_message ADD COLUMN source_ip VARCHAR(45); |
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
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
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
75 changes: 75 additions & 0 deletions
75
.../dspace/app/rest/repository/patch/operation/ldn/NotifyServiceLowerIpReplaceOperation.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,75 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.repository.patch.operation.ldn; | ||
|
||
import java.sql.SQLException; | ||
|
||
import org.dspace.app.ldn.NotifyServiceEntity; | ||
import org.dspace.app.ldn.service.NotifyService; | ||
import org.dspace.app.rest.exception.DSpaceBadRequestException; | ||
import org.dspace.app.rest.exception.UnprocessableEntityException; | ||
import org.dspace.app.rest.model.patch.Operation; | ||
import org.dspace.app.rest.repository.patch.operation.PatchOperation; | ||
import org.dspace.core.Context; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Implementation for NotifyService lowerIp Replace patches. | ||
* | ||
* Example: <code> | ||
* curl -X PATCH http://${dspace.server.url}/api/ldn/ldnservices/<:id-notifyService> -H " | ||
* Content-Type: application/json" -d ' | ||
* [{ | ||
* "op": "replace", | ||
* "path": "/lowerIp", | ||
* "value": "lowerIp value" | ||
* }]' | ||
* </code> | ||
*/ | ||
@Component | ||
public class NotifyServiceLowerIpReplaceOperation extends PatchOperation<NotifyServiceEntity> { | ||
|
||
@Autowired | ||
private NotifyService notifyService; | ||
|
||
private static final String OPERATION_PATH = "/lowerip"; | ||
|
||
@Override | ||
public NotifyServiceEntity perform(Context context, NotifyServiceEntity notifyServiceEntity, Operation operation) | ||
throws SQLException { | ||
checkOperationValue(operation.getValue()); | ||
|
||
Object lowerIp = operation.getValue(); | ||
if (lowerIp == null | !(lowerIp instanceof String)) { | ||
throw new UnprocessableEntityException("The /lowerIp value must be a string"); | ||
} | ||
|
||
checkModelForExistingValue(notifyServiceEntity); | ||
notifyServiceEntity.setLowerIp((String) lowerIp); | ||
notifyService.update(context, notifyServiceEntity); | ||
return notifyServiceEntity; | ||
} | ||
|
||
/** | ||
* Checks whether the lowerIp of notifyServiceEntity has an existing value to replace | ||
* @param notifyServiceEntity Object on which patch is being done | ||
*/ | ||
private void checkModelForExistingValue(NotifyServiceEntity notifyServiceEntity) { | ||
if (notifyServiceEntity.getLowerIp() == null) { | ||
throw new DSpaceBadRequestException("Attempting to replace a non-existent value (lowerIp)."); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean supports(Object objectToMatch, Operation operation) { | ||
return (objectToMatch instanceof NotifyServiceEntity && | ||
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) && | ||
operation.getPath().trim().toLowerCase().equalsIgnoreCase(OPERATION_PATH)); | ||
} | ||
} |
Oops, something went wrong.