Search in sources :

Example 1 with AbstractApplicationMgtListener

use of org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener in project carbon-identity-framework by wso2.

the class ApplicationManagementServiceImpl method getPaginatedApplicationBasicInfo.

/**
 * Get all basic application information for a matching filter with pagination.
 *
 * @param tenantDomain Tenant Domain
 * @param username     User Name
 * @param filter       Application name filter
 * @param pageNumber   Number of the page
 * @return Application Basic Information array
 * @throws IdentityApplicationManagementException
 */
@Override
public ApplicationBasicInfo[] getPaginatedApplicationBasicInfo(String tenantDomain, String username, int pageNumber, String filter) throws IdentityApplicationManagementException {
    ApplicationBasicInfo[] applicationBasicInfoArray;
    try {
        startTenantFlow(tenantDomain, username);
        ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
        // invoking pre listeners
        if (appDAO instanceof PaginatableFilterableApplicationDAO) {
            Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPreGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber, filter)) {
                    return new ApplicationBasicInfo[0];
                }
            }
            applicationBasicInfoArray = ((PaginatableFilterableApplicationDAO) appDAO).getPaginatedApplicationBasicInfo(pageNumber, filter);
            // invoking post listeners
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPostGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber, filter, applicationBasicInfoArray)) {
                    return new ApplicationBasicInfo[0];
                }
            }
        } else {
            throw new UnsupportedOperationException("Application filtering and pagination not supported. " + "Tenant domain: " + tenantDomain);
        }
    } finally {
        endTenantFlow();
    }
    return applicationBasicInfoArray;
}
Also used : PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationBasicInfo(org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener)

Example 2 with AbstractApplicationMgtListener

use of org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener in project carbon-identity-framework by wso2.

the class ApplicationManagementServiceImpl method getApplicationBasicInfo.

/**
 * Get all basic application information for a matching filter with pagination based on the offset and limit.
 *
 * @param tenantDomain Tenant Domain.
 * @param username     User name.
 * @param filter       Application name filter.
 * @param offset       Starting index of the count.
 * @param limit        Counting value.
 * @return An array of {@link ApplicationBasicInfo} instances within the limit.
 * @throws IdentityApplicationManagementException Error in retrieving basic application information.
 */
@Override
public ApplicationBasicInfo[] getApplicationBasicInfo(String tenantDomain, String username, String filter, int offset, int limit) throws IdentityApplicationManagementException {
    ApplicationBasicInfo[] applicationBasicInfoArray;
    try {
        startTenantFlow(tenantDomain, username);
        ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
        if (appDAO instanceof PaginatableFilterableApplicationDAO) {
            // Invoking pre listeners.
            Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPreGetApplicationBasicInfo(tenantDomain, username, filter, offset, limit)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Invoking pre listener: " + listener.getClass().getName());
                    }
                    return new ApplicationBasicInfo[0];
                }
            }
            applicationBasicInfoArray = ((PaginatableFilterableApplicationDAO) appDAO).getApplicationBasicInfo(filter, offset, limit);
            // Invoking post listeners.
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPostGetApplicationBasicInfo(tenantDomain, username, filter, offset, limit, applicationBasicInfoArray)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Invoking post listener: " + listener.getClass().getName());
                    }
                    return new ApplicationBasicInfo[0];
                }
            }
        } else {
            throw new UnsupportedOperationException("Application filtering and pagination not supported in " + appDAO.getClass().getName() + " with tenant domain: " + tenantDomain);
        }
    } finally {
        endTenantFlow();
    }
    return applicationBasicInfoArray;
}
Also used : PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationBasicInfo(org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener)

Example 3 with AbstractApplicationMgtListener

use of org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener in project carbon-identity-framework by wso2.

the class ApplicationManagementServiceImpl method getAllPaginatedApplicationBasicInfo.

/**
 * Get All Application Basic Information with pagination
 *
 * @param tenantDomain Tenant Domain
 * @param username     User Name
 * @param pageNumber   Number of the page
 * @return ApplicationBasicInfo[]
 * @throws IdentityApplicationManagementException
 */
@Override
public ApplicationBasicInfo[] getAllPaginatedApplicationBasicInfo(String tenantDomain, String username, int pageNumber) throws IdentityApplicationManagementException {
    ApplicationBasicInfo[] applicationBasicInfoArray;
    try {
        startTenantFlow(tenantDomain, username);
        ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
        if (appDAO instanceof PaginatableFilterableApplicationDAO) {
            // invoking pre listeners
            Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPreGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber)) {
                    return new ApplicationBasicInfo[0];
                }
            }
            applicationBasicInfoArray = ((PaginatableFilterableApplicationDAO) appDAO).getAllPaginatedApplicationBasicInfo(pageNumber);
            // invoking post listeners
            for (ApplicationMgtListener listener : listeners) {
                if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPostGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber, applicationBasicInfoArray)) {
                    return new ApplicationBasicInfo[0];
                }
            }
        } else {
            throw new UnsupportedOperationException("Application pagination is not supported. Tenant domain: " + tenantDomain);
        }
    } finally {
        endTenantFlow();
    }
    return applicationBasicInfoArray;
}
Also used : PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationBasicInfo(org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener)

Aggregations

ApplicationBasicInfo (org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo)3 ApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO)3 PaginatableFilterableApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO)3 FileBasedApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO)3 AbstractApplicationMgtListener (org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener)3 ApplicationMgtListener (org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener)3