@Test public void testvalidateArtifactResolution() { Response res = resource.validateArtifactResolution(null, null); Assert.assertNull(res); res = resource.validateArtifactResolution("", ""); Assert.assertNull(res); res = resource.validateArtifactResolution("testEndpoint", "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertNull(res); res = resource.validateArtifactResolution("", "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("testEndpoint", ""); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution(null, "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("tesetEndpoint", null); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("tesetEndpoint", "ccf4f3895f6e37896e7511ed1d991b1d96f"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); }
protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); }
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); } }
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); }  }
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); }  @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
            @Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); }  @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
            @Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }