package org.gluu.oxtrust.ws.rs.passport;

import java.util.Collections;
import java.util.Optional;

import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.gluu.oxtrust.ldap.service.PassportService;
import org.gluu.oxtrust.service.filter.ProtectedApi;
import org.slf4j.Logger;
import org.xdi.config.oxtrust.LdapOxPassportConfiguration;
import org.xdi.service.JsonService;

import static javax.ws.rs.core.Response.Status;

/**
 * PassportConfigurationEndPoint Implementation
 * 
 * @author Shekhar L.
 * @author Yuriy Movchan Date: 12/06/2016
 */

@Named("PassportConfigurationEndPoint")
@Path("/passport/config")
public class PassportRestWebService {

    @Inject
    private Logger log;

	@Inject
	private PassportService passportService;

	@Inject
	private JsonService jsonService;

	@GET
	@Produces({ MediaType.APPLICATION_JSON })
    @ProtectedApi
	public Response getPassportConfig() {

	    Status status;
        String jsonResponse;

        try {
            Object obj = Optional.ofNullable(passportService.loadConfigurationFromLdap())
                    .map(LdapOxPassportConfiguration::getPassportConfigurations)
                    .map(list -> list.isEmpty() ? (Object) null : list.get(0)).orElse(Collections.emptyMap());

            jsonResponse = jsonService.objectToPerttyJson(obj);
            status = Status.OK;
        } catch (Exception e) {
            jsonResponse = "Failed to prepare configuration: " + e.getMessage();
            status = Status.INTERNAL_SERVER_ERROR;
            log.error(e.getMessage(), e);
        }

        log.trace("Passport endpoint config response is\n{}", jsonResponse);
        return Response.status(status).entity(jsonResponse).build();

	}

}

@@ -1275,17 +1275,16 @@
 guration
-s
 )%0A      
@@ -1306,61 +1306,48 @@
 map(
-list -%3E list.isEmpty() ? (Object) null : list.get(0))
+Object.class::cast)%0A                    
 .orE

Update rest service to conform to latest oxcore refactoring