-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started with subscription resource REST endpoints.
- Loading branch information
Showing
92 changed files
with
3,621 additions
and
402 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
common/src/main/java/org/dhis2/fhir/adapter/jackson/PersistentBagConverter.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,68 @@ | ||
package org.dhis2.fhir.adapter.jackson; | ||
|
||
/* | ||
* Copyright (c) 2004-2018, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.type.TypeFactory; | ||
import com.fasterxml.jackson.databind.util.Converter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Converts lists (especially persistent bag) to a list. | ||
* This is required when class name is serialized and used sorted set class | ||
* cannot be instantiated otherwise. | ||
* | ||
* @author volsch | ||
*/ | ||
public class PersistentBagConverter implements Converter<List<?>, List<?>> | ||
{ | ||
@Override | ||
public List<?> convert( List<?> value ) | ||
{ | ||
if ( value == null ) | ||
{ | ||
return null; | ||
} | ||
return new ArrayList<>( value ); | ||
} | ||
|
||
@Override | ||
public JavaType getInputType( TypeFactory typeFactory ) | ||
{ | ||
return typeFactory.constructCollectionType( List.class, Object.class ); | ||
} | ||
|
||
@Override | ||
public JavaType getOutputType( TypeFactory typeFactory ) | ||
{ | ||
return typeFactory.constructCollectionType( ArrayList.class, Object.class ); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
common/src/main/java/org/dhis2/fhir/adapter/jackson/TypedPersistentSortedSetConverter.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,77 @@ | ||
package org.dhis2.fhir.adapter.jackson; | ||
|
||
/* | ||
* Copyright (c) 2004-2018, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.type.TypeFactory; | ||
import com.fasterxml.jackson.databind.util.Converter; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
/** | ||
* Converts sorted sets (especially persistent sorted set) to a tree set. | ||
* This is required when class name is serialized and used sorted set class | ||
* cannot be instantiated otherwise. | ||
* | ||
* @param <T> the concrete type of the item class. | ||
* @author volsch | ||
*/ | ||
public class TypedPersistentSortedSetConverter<T> implements Converter<SortedSet<T>, TreeSet<T>> | ||
{ | ||
private final Class<T> itemClass; | ||
|
||
public TypedPersistentSortedSetConverter( @Nonnull Class<T> itemClass ) | ||
{ | ||
this.itemClass = itemClass; | ||
} | ||
|
||
@Override | ||
public TreeSet<T> convert( SortedSet<T> value ) | ||
{ | ||
if ( value == null ) | ||
{ | ||
return null; | ||
} | ||
return new TreeSet<>( value ); | ||
} | ||
|
||
@Override | ||
public JavaType getInputType( TypeFactory typeFactory ) | ||
{ | ||
return typeFactory.constructCollectionType( SortedSet.class, itemClass ); | ||
} | ||
|
||
@Override | ||
public JavaType getOutputType( TypeFactory typeFactory ) | ||
{ | ||
return typeFactory.constructCollectionType( TreeSet.class, itemClass ); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
common/src/main/java/org/dhis2/fhir/adapter/rest/RestBadRequestException.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,71 @@ | ||
package org.dhis2.fhir.adapter.rest; | ||
|
||
/* | ||
* Copyright (c) 2004-2018, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Thrown if the request cannot be handled because the input data is invalid. | ||
* The exception contains status code 400 that should be returned to a client. | ||
* | ||
* @author volsch | ||
*/ | ||
public class RestBadRequestException extends RestResponseEntityException | ||
{ | ||
private static final long serialVersionUID = -7487909336857881610L; | ||
|
||
public RestBadRequestException() | ||
{ | ||
super(); | ||
} | ||
|
||
public RestBadRequestException( String message ) | ||
{ | ||
super( message ); | ||
} | ||
|
||
public RestBadRequestException( String message, Throwable cause ) | ||
{ | ||
super( message, cause ); | ||
} | ||
|
||
public RestBadRequestException( Throwable cause ) | ||
{ | ||
super( cause ); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public HttpStatus getHttpStatus() | ||
{ | ||
return HttpStatus.BAD_REQUEST; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
common/src/main/java/org/dhis2/fhir/adapter/rest/RestError.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,59 @@ | ||
package org.dhis2.fhir.adapter.rest; | ||
|
||
/* | ||
* Copyright (c) 2004-2018, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import reactor.util.annotation.NonNull; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* Error message that is serialized to the client in case of an error. | ||
* | ||
* @author volsch | ||
*/ | ||
public class RestError implements Serializable | ||
{ | ||
private static final long serialVersionUID = 1604874907010817024L; | ||
|
||
private final String message; | ||
|
||
public RestError( @Nonnull String message ) | ||
{ | ||
this.message = message; | ||
} | ||
|
||
@JsonProperty | ||
@NonNull | ||
public String getMessage() | ||
{ | ||
return message; | ||
} | ||
} |
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
Oops, something went wrong.