Search in sources :

Example 1 with KeyValueBasedPcrDAOImpl

use of com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl in project core-util by WSO2Telco.

the class UUIDPCRService method createAndPersistNewPcr.

private String createAndPersistNewPcr(RequestDTO requestDTO) throws PCRException {
    KeyValueBasedPcrDAOImpl keyValueBasedPcrDAO = new KeyValueBasedPcrDAOImpl();
    UUID uuidPcr = UUID.randomUUID();
    keyValueBasedPcrDAO.createNewPcrEntry(requestDTO, uuidPcr.toString());
    return uuidPcr.toString();
}
Also used : KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) UUID(java.util.UUID)

Example 2 with KeyValueBasedPcrDAOImpl

use of com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl in project core-util by WSO2Telco.

the class UUIDPCRService method updateServiceProviderMap.

private void updateServiceProviderMap(String appId) throws PCRException {
    if (DEBUG)
        log.debug("Updating Service Provider Map");
    try {
        OAuthConsumerAppDTO apps = authApplicationData.getApplicationData(appId);
        if (DEBUG)
            log.debug("Application List recieved");
        if (apps == null) {
            log.error("Application data not found - updateServiceProviderMap");
            throw new PCRException("Null Application list - updateServiceProviderMap");
        }
        String callbackUrl = apps.getCallbackUrl();
        String sector = SectorUtil.getSectorIdFromUrl(callbackUrl);
        KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
        keyValueBasedPcrDAOImpl.createNewSPEntry(sector, appId, true);
    } catch (Exception e) {
        log.error("error in retrieving application data - updateServiceProviderMap", e);
        throw new PCRException("error in retrieving application data - updateServiceProviderMap");
    }
}
Also used : PCRException(com.wso2telco.core.pcrservice.exception.PCRException) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Example 3 with KeyValueBasedPcrDAOImpl

use of com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl in project core-util by WSO2Telco.

the class KeyValueBasedPcrDAOImplTest method testCreateNewPcrEntry.

@Test
public void testCreateNewPcrEntry() throws PCRException {
    RequestDTO dto = new RequestDTO("u", "a", "s");
    RequestDTO dto1 = new RequestDTO("u1", "a1", "s1");
    RequestDTO dto2 = new RequestDTO("u1", "a2", "s1");
    RequestDTO dto3 = new RequestDTO("u3", "a3", "s3");
    RequestDTO dto4 = new RequestDTO("u4", "a4", "s4");
    RequestDTO dto5 = new RequestDTO("u5", "a5", "s5");
    RequestDTO dto6 = new RequestDTO("u6", "a6", "s6");
    RequestDTO dto7 = new RequestDTO("u7", "a7", "s7");
    RequestDTO dto8 = new RequestDTO("u8", "a8", "s8");
    RequestDTO dto9 = new RequestDTO("u9", "a9", "s9");
    RequestDTO dto0 = new RequestDTO("u0", "a0", "s0");
    KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto, "p");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto1, "p1");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto2, "p1");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto3, "p3");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto4, "p4");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto5, "p5");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto6, "p6");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto7, "p7");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto8, "p8");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto9, "p9");
    keyValueBasedPcrDAOImpl.createNewPcrEntry(dto0, "p0");
}
Also used : RequestDTO(com.wso2telco.core.pcrservice.model.RequestDTO) KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) Test(org.junit.Test)

Example 4 with KeyValueBasedPcrDAOImpl

use of com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl in project core-util by WSO2Telco.

the class KeyValueBasedPcrDAOImplTest method testgetRelatedApplicationIdList.

@Test
public void testgetRelatedApplicationIdList() throws PCRException {
    KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
    List<String> list = keyValueBasedPcrDAOImpl.getApplicationIdList("s1");
    assertEquals(list.get(0), "a2");
    assertEquals(list.get(1), "a1");
}
Also used : KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) Test(org.junit.Test)

Example 5 with KeyValueBasedPcrDAOImpl

use of com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl in project core-util by WSO2Telco.

the class KeyValueBasedPcrDAOImplTest method testcreateNewSPEntry.

@Test
public void testcreateNewSPEntry() throws PCRException {
    KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
    keyValueBasedPcrDAOImpl.createNewSPEntry("s1", "a1", true);
    keyValueBasedPcrDAOImpl.createNewSPEntry("s1", "a2", true);
}
Also used : KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) Test(org.junit.Test)

Aggregations

KeyValueBasedPcrDAOImpl (com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl)12 Test (org.junit.Test)7 RequestDTO (com.wso2telco.core.pcrservice.model.RequestDTO)3 PCRException (com.wso2telco.core.pcrservice.exception.PCRException)2 UUID (java.util.UUID)1 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)1