-
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.
added new routes for UserSkills, UserRoutes, and StudioUsers PR (#6)
* added new routes for UserSkills, UserRoutes, and StudioUsers * added new routes for UserSkills, UserRoutes, and StudioUsers * avoiding single statement if clauses by adding {}
- Loading branch information
1 parent
665b1f2
commit 3c52b0c
Showing
14 changed files
with
239 additions
and
53 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/com/gamedoora/backend/proxy/aggregation/api/StudioDataAggregationService.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,29 @@ | ||
package com.gamedoora.backend.proxy.aggregation.api; | ||
|
||
import com.gamedoora.backend.proxy.aggregation.assembler.StudioDataAggregatorAssembler; | ||
import com.gamedoora.model.dto.GdUser; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping(value = "/aggregate/studios") | ||
public class StudioDataAggregationService { | ||
private StudioDataAggregatorAssembler studioDataAggregatorAssembler; | ||
|
||
@RequestMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public GdUser getStudiosByUser(@RequestParam("email") String email){ | ||
return getStudioDataAggregatorAssembler().getStudiosByUser(email); | ||
} | ||
|
||
public StudioDataAggregatorAssembler getStudioDataAggregatorAssembler() { | ||
return studioDataAggregatorAssembler; | ||
} | ||
|
||
@Autowired | ||
public void setStudioDataAggregatorAssembler(StudioDataAggregatorAssembler studioDataAggregatorAssembler) { | ||
this.studioDataAggregatorAssembler = studioDataAggregatorAssembler; | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...java/com/gamedoora/backend/proxy/aggregation/assembler/StudioDataAggregatorAssembler.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,35 @@ | ||
package com.gamedoora.backend.proxy.aggregation.assembler; | ||
|
||
import com.gamedoora.backend.proxy.aggregation.routes.StudioProfileRoute; | ||
import com.gamedoora.model.dto.GdUser; | ||
import com.gamedoora.model.dto.StudiosDTO; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.ProducerTemplate; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class StudioDataAggregatorAssembler { | ||
private ProducerTemplate producerTemplate; | ||
|
||
@Autowired | ||
private CamelContext camelContext; | ||
private StudioProfileRoute studioProfileRoute; | ||
|
||
public GdUser getStudiosByUser(String email){ | ||
List<StudiosDTO> studioDTOList = getProducerTemplate().requestBody("direct:studioUserQuery" , email, ArrayList.class); | ||
return GdUser | ||
.builder() | ||
.studios(studioDTOList) | ||
.build(); | ||
} | ||
|
||
public ProducerTemplate getProducerTemplate() { | ||
return producerTemplate; | ||
} | ||
|
||
public void setProducerTemplate(ProducerTemplate producerTemplate) { | ||
this.producerTemplate = producerTemplate; | ||
} | ||
} |
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
19 changes: 0 additions & 19 deletions
19
src/main/java/com/gamedoora/backend/proxy/aggregation/config/CamelConfig.java
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/main/java/com/gamedoora/backend/proxy/aggregation/config/FeignClientConfig.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/com/gamedoora/backend/proxy/aggregation/enrichment/apis/StudioServicesApi.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,21 @@ | ||
package com.gamedoora.backend.proxy.aggregation.enrichment.apis; | ||
|
||
import com.gamedoora.model.dto.StudiosDTO; | ||
import org.springframework.cloud.context.config.annotation.RefreshScope; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
|
||
import java.util.List; | ||
|
||
@RefreshScope | ||
@FeignClient(value = "studiosClient", url = "{services.studios.url}") | ||
public interface StudioServicesApi { | ||
|
||
@GetMapping( | ||
value = "/users/{email}", | ||
produces = {MediaType.APPLICATION_JSON_VALUE}) | ||
ResponseEntity <List<StudiosDTO>> getStudiosByUser(@PathVariable String email); | ||
} |
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
38 changes: 38 additions & 0 deletions
38
...amedoora/backend/proxy/aggregation/enrichment/clients/RetriableStudiosServicesClient.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,38 @@ | ||
package com.gamedoora.backend.proxy.aggregation.enrichment.clients; | ||
|
||
import com.gamedoora.model.dto.StudiosDTO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.retry.support.RetryTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class RetriableStudiosServicesClient { | ||
|
||
private StudioServicesClient studioServicesClient; | ||
|
||
private RetryTemplate retryTemplate; | ||
|
||
public List<StudiosDTO> getStudiosForUserByEmail(String email){ | ||
return getRetryTemplate().execute(retryContext -> getStudioServicesClient().getStudiosByUser(email)); | ||
} | ||
|
||
public StudioServicesClient getStudioServicesClient() { | ||
return studioServicesClient; | ||
} | ||
|
||
@Autowired | ||
public void setStudioServicesClient(StudioServicesClient studioServicesClient) { | ||
this.studioServicesClient = studioServicesClient; | ||
} | ||
|
||
public RetryTemplate getRetryTemplate() { | ||
return retryTemplate; | ||
} | ||
|
||
@Autowired | ||
public void setRetryTemplate(RetryTemplate retryTemplate) { | ||
this.retryTemplate = retryTemplate; | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
...java/com/gamedoora/backend/proxy/aggregation/enrichment/clients/StudioServicesClient.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,27 @@ | ||
package com.gamedoora.backend.proxy.aggregation.enrichment.clients; | ||
|
||
import com.gamedoora.backend.proxy.aggregation.enrichment.apis.StudioServicesApi; | ||
import com.gamedoora.model.dto.StudiosDTO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class StudioServicesClient { | ||
|
||
private StudioServicesApi studioServicesApi; | ||
|
||
public StudioServicesApi getStudioServicesApi() { | ||
return studioServicesApi; | ||
} | ||
|
||
@Autowired | ||
public void setStudioServicesApi(StudioServicesApi studioServicesApi) { | ||
this.studioServicesApi = studioServicesApi; | ||
} | ||
|
||
public List<StudiosDTO> getStudiosByUser(String email) { | ||
return getStudioServicesApi().getStudiosByUser(email).getBody(); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/gamedoora/backend/proxy/aggregation/routes/StudioProfileRoute.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,24 @@ | ||
package com.gamedoora.backend.proxy.aggregation.routes; | ||
|
||
import com.gamedoora.backend.proxy.aggregation.enrichment.clients.RetriableStudiosServicesClient; | ||
import feign.FeignException; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StudioProfileRoute extends RouteBuilder { | ||
|
||
private RetriableStudiosServicesClient studiosServicesClient; | ||
|
||
@Override | ||
public void configure() throws Exception{ | ||
onException(FeignException.class) | ||
.maximumRedeliveries(3) | ||
.logStackTrace(true) | ||
.handled(false); | ||
|
||
from("direct:studioQuery") | ||
.to("bean:retriableStudiosServicesClient?method=getStudioForUserByEmail") | ||
.end(); | ||
} | ||
} |
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