Search in sources :

Example 11 with SMDiscoveryServiceData

use of com.sun.identity.console.service.model.SMDiscoveryServiceData in project OpenAM by OpenRock.

the class UMUserResourceOfferingModelImpl method getUserDiscoEntry.

/**
     * Returns resource offering entry stored for a given Universal ID of user.
     *
     * @param userId Universal ID of user.
     * @return resource offering entry stored for a given user.
     * @throws AMConsoleException if entry cannot be determined.
     */
public SMDiscoveryServiceData getUserDiscoEntry(String userId) throws AMConsoleException {
    SMDiscoveryServiceData resourceOffering = null;
    String[] params = { userId, AMAdminConstants.ATTR_USER_RESOURCE_OFFERING };
    try {
        logEvent("ATTEMPT_READ_IDENTITY_ATTRIBUTE_VALUE", params);
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
        resourceOffering = SMDiscoveryServiceData.getEntries(amid.getAttribute(AMAdminConstants.ATTR_USER_RESOURCE_OFFERING), SMDiscoveryServiceData.USER_RESOURCE_OFFERING_ENTRY);
        resourceOffering.setEntryType(SMDiscoveryServiceData.USER_RESOURCE_OFFERING_ENTRY);
        logEvent("SUCCEED_READ_IDENTITY_ATTRIBUTE_VALUE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_RESOURCE_OFFERING, strError };
        logEvent("SSO_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_RESOURCE_OFFERING, strError };
        logEvent("IDM_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    }
    return resourceOffering;
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 12 with SMDiscoveryServiceData

use of com.sun.identity.console.service.model.SMDiscoveryServiceData in project OpenAM by OpenRock.

the class RealmResourceOfferingViewBean method handleTblButtonDeleteRequest.

public void handleTblButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_ENTRIES);
    table.restoreStateData();
    RealmResourceOfferingModel model = (RealmResourceOfferingModel) getModel();
    String realm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    DiscoveryDataCache cache = DiscoveryDataCache.getInstance();
    String cacheID = (String) getPageSessionAttribute(RealmResourceOfferingViewBean.DATA_ID);
    SMDiscoveryServiceData smEntry = cache.getData(model.getUserSSOToken(), cacheID);
    Integer[] selected = tblModel.getSelectedRows();
    smEntry.deleteDiscoEntries(selected);
    try {
        model.setRealmDiscoEntry(realm, smEntry);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "discovery.service.table.entry.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "discovery.service.table.entry.deleted.pural");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) CCActionTable(com.sun.web.ui.view.table.CCActionTable) RealmResourceOfferingModel(com.sun.identity.console.realm.model.RealmResourceOfferingModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) DiscoveryDataCache(com.sun.identity.console.service.model.DiscoveryDataCache)

Example 13 with SMDiscoveryServiceData

use of com.sun.identity.console.service.model.SMDiscoveryServiceData in project OpenAM by OpenRock.

the class RealmResourceOfferingModelImpl method getRealmDiscoEntry.

/**
     * Returns resource offering entry stored for a realm name.
     *
     * @param realm Realm Name.
     * @return resource offering entry stored for a given user.
     * @throws AMConsoleException if entry cannot be determined.
     */
public SMDiscoveryServiceData getRealmDiscoEntry(String realm) throws AMConsoleException {
    SMDiscoveryServiceData resourceOffering = null;
    String[] params = { realm, AMAdminConstants.DISCOVERY_SERVICE, AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES };
    logEvent("ATTEMPT_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
    try {
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realm);
        AMIdentity realmIdentity = repo.getRealmIdentity();
        Set servicesFromIdRepo = realmIdentity.getAssignedServices();
        Map map = null;
        if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
            map = realmIdentity.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE);
        } else {
            OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realm);
            map = orgCfgMgr.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE);
        }
        logEvent("SUCCEED_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
        resourceOffering = SMDiscoveryServiceData.getEntries((Set) map.get(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES));
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SSO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("IDREPO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SMS_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
    }
    return resourceOffering;
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with SMDiscoveryServiceData

use of com.sun.identity.console.service.model.SMDiscoveryServiceData in project OpenAM by OpenRock.

the class SMDiscoveryServiceViewBean method populateBootstrapResOffTable.

private void populateBootstrapResOffTable(Set resoff) {
    tablePopulated = true;
    if (resoff != null) {
        CCActionTableModel tblModel = (CCActionTableModel) propertySheetModel.getModel(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
        tblModel.clearAll();
        boolean firstEntry = true;
        int counter = 0;
        try {
            SMDiscoveryServiceData smEntry = SMDiscoveryServiceData.getEntries(resoff);
            List resourceList = smEntry.getResourceData();
            if ((resourceList != null) && !resourceList.isEmpty()) {
                for (Iterator i = resourceList.iterator(); i.hasNext(); ) {
                    SMDiscoEntryData smDisco = (SMDiscoEntryData) i.next();
                    if (!firstEntry) {
                        tblModel.appendRow();
                    } else {
                        firstEntry = false;
                    }
                    tblModel.setValue(TBL_BOOTSTRAP_RES_OFF_DATA_SERVICE_TYPE, smDisco.serviceType);
                    tblModel.setValue(TBL_BOOTSTRAP_RES_OFF_DATA_ABSTRACT, smDisco.abstractValue);
                    tblModel.setValue(TBL_BOOTSTRAP_RES_OFF_HREF_ACTION, Integer.toString(counter));
                    counter++;
                }
                disableButton(TBL_BOOTSTRAP_RES_OFF_ADD_BTN, true);
            } else {
                disableButton(TBL_BOOTSTRAP_RES_OFF_ADD_BTN, false);
            }
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
    setPageSessionAttribute(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF, (OrderedSet) resoff);
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) SMDiscoEntryData(com.sun.identity.console.service.model.SMDiscoEntryData) CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) Iterator(java.util.Iterator) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with SMDiscoveryServiceData

use of com.sun.identity.console.service.model.SMDiscoveryServiceData in project OpenAM by OpenRock.

the class SMDiscoveryBootstrapRefOffEditViewBean method handleButton1Request.

protected void handleButton1Request(SMDiscoEntryData smData) throws AMConsoleException {
    SMDiscoveryServiceViewBean vb = (SMDiscoveryServiceViewBean) getViewBean(SMDiscoveryServiceViewBean.class);
    Map mapAttrs = (Map) getPageSessionAttribute(SMDiscoveryServiceViewBean.PROPERTY_ATTRIBUTE);
    OrderedSet resoff = (OrderedSet) mapAttrs.get(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
    SMDiscoveryServiceData smEntry = SMDiscoveryServiceData.getEntries(resoff);
    int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
    smEntry.replaceResourceData(index, smData);
    mapAttrs.put(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF, (OrderedSet) smEntry.getDiscoveryEntries());
    setPageSessionAttribute(SMDiscoveryServiceViewBean.PROPERTY_ATTRIBUTE, (HashMap) mapAttrs);
    setPageSessionAttribute(SMDiscoveryServiceViewBean.PAGE_MODIFIED, "1");
    backTrail();
    unlockPageTrailForSwapping();
    passPgSessionMap(vb);
    vb.forwardTo(getRequestContext());
}
Also used : OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SMDiscoveryServiceData (com.sun.identity.console.service.model.SMDiscoveryServiceData)21 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)15 DiscoveryDataCache (com.sun.identity.console.service.model.DiscoveryDataCache)13 SMDiscoEntryData (com.sun.identity.console.service.model.SMDiscoEntryData)5 List (java.util.List)5 Map (java.util.Map)5 UMUserResourceOfferingModel (com.sun.identity.console.user.model.UMUserResourceOfferingModel)4 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)4 CCActionTable (com.sun.web.ui.view.table.CCActionTable)4 HashMap (java.util.HashMap)4 SSOException (com.iplanet.sso.SSOException)3 EntityResourceOfferingModel (com.sun.identity.console.idm.model.EntityResourceOfferingModel)3 RealmResourceOfferingModel (com.sun.identity.console.realm.model.RealmResourceOfferingModel)3 AMIdentity (com.sun.identity.idm.AMIdentity)3 IdRepoException (com.sun.identity.idm.IdRepoException)3 Set (java.util.Set)3 CCActionTableModel (com.sun.web.ui.model.CCActionTableModel)2 Iterator (java.util.Iterator)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 SMDescriptionData (com.sun.identity.console.service.model.SMDescriptionData)1