Search in sources :

Example 1 with Client

use of com.iplanet.services.cdm.Client in project OpenAM by OpenRock.

the class MAPModelBase method getAdditionalPropertyValues.

protected Set getAdditionalPropertyValues(String clientType) {
    Set values = Collections.EMPTY_SET;
    Client client = clientTypesManager.getClientInstance(clientType);
    if (client != null) {
        values = client.getAdditionalProperties();
    }
    return values;
}
Also used : Set(java.util.Set) Client(com.iplanet.services.cdm.Client)

Example 2 with Client

use of com.iplanet.services.cdm.Client in project OpenAM by OpenRock.

the class AMI18NUtils method getContentType.

/**
     * Returns content type from client service API.
     *
     * @param clientType Client type.
     * @return content type.
     */
public static String getContentType(String clientType) {
    String contentType;
    if (clientDt.isDetectionEnabled()) {
        try {
            Client client = ClientsManager.getInstance(clientType);
            contentType = (client != null) ? client.getProperty(AMAdminConstants.CDM_CONTENT_TYPE_PROPERTY_NAME) : Client.CDM_DEFAULT_CLIENT_TYPE;
        } catch (ClientException ce) {
            debug.warning("AMI18NUtils.getContentType - " + "couldn't retrieve the content type, reverting to default.");
            contentType = Client.CDM_DEFAULT_CLIENT_TYPE;
        }
    } else {
        contentType = Client.CDM_DEFAULT_CLIENT_TYPE;
    }
    return contentType;
}
Also used : ClientException(com.iplanet.services.cdm.ClientException) Client(com.iplanet.services.cdm.Client)

Example 3 with Client

use of com.iplanet.services.cdm.Client in project OpenAM by OpenRock.

the class AMI18NUtils method getCharset.

/**
     * Returns charset type from client service API
     *
     * @param clientType Client type.
     * @param loc Locale of request.
     * @return charset.
     */
public static String getCharset(String clientType, java.util.Locale loc) {
    String charset;
    if (clientDt.isDetectionEnabled()) {
        try {
            Client client = ClientsManager.getInstance(clientType);
            charset = (client != null) ? client.getCharset(loc) : Client.CDM_DEFAULT_CHARSET;
        } catch (ClientException ce) {
            debug.warning("AMI18NUtils.getCharset - " + "couldn't retrieve the client charset, reverting to default.");
            charset = Client.CDM_DEFAULT_CHARSET;
        }
    } else {
        charset = Client.CDM_DEFAULT_CHARSET;
    }
    return charset;
}
Also used : ClientException(com.iplanet.services.cdm.ClientException) Client(com.iplanet.services.cdm.Client)

Example 4 with Client

use of com.iplanet.services.cdm.Client in project OpenAM by OpenRock.

the class MAPDeviceProfileModelImpl method getAttributeValues.

/**
     * Returns attribute values of a device.
     *
     * @param clientType Client Type.
     * @param classification Profile attribute classification.
     * @return attribute values of a device.
     */
public Map getAttributeValues(String clientType, String classification) {
    String[] params = { clientType, classification };
    logEvent("ATTEMPT_CLIENT_DETECTION_GET_CLIENT_PROFILE", params);
    Set attributeNames = getAttributeNames(clientType, classification);
    Map attributeValues = new HashMap(attributeNames.size() * 2);
    if (classification.equals(ADDITIONAL_PROPERTIES_CLASSIFICAIION)) {
        Set values = getAdditionalPropertyValues(clientType);
        if ((values == null) || values.isEmpty()) {
            values = new HashSet(1);
            values.add("");
        }
        String attrName = (String) attributeNames.iterator().next();
        attributeValues = new HashMap(2);
        attributeValues.put(attrName, values);
    } else {
        Client client = clientTypesManager.getClientInstance(clientType);
        if (client != null) {
            for (Iterator i = attributeNames.iterator(); i.hasNext(); ) {
                String name = (String) i.next();
                Set values = client.getProperties(name);
                if ((values == null) || values.isEmpty()) {
                    values = Collections.EMPTY_SET;
                    AttributeSchema as = getDeviceAttributeSchema(name);
                    if (as.getSyntax().equals(AttributeSchema.Syntax.BOOLEAN)) {
                        values = new HashSet(2);
                        values.add(AMAdminConstants.STRING_FALSE);
                    }
                }
                attributeValues.put(name, values);
            }
        }
    }
    logEvent("SUCCEED_CLIENT_DETECTION_GET_CLIENT_PROFILE", params);
    return (attributeValues != null) ? attributeValues : Collections.EMPTY_MAP;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) Client(com.iplanet.services.cdm.Client) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 5 with Client

use of com.iplanet.services.cdm.Client in project OpenAM by OpenRock.

the class BasicClientTypesManager method populateClient.

/**
     * Simple utility method that parsed the properties file for the different
     * clients.
     *
     * @param clientName The name of the client to populate
     * @param props The incoming properties file
     * @throws InvalidPropertiesFormatException
     */
protected void populateClient(String clientName, Properties props) throws InvalidPropertiesFormatException {
    String name = props.getProperty(clientName + NAME_SUFFIX);
    String attrList = props.getProperty(clientName + ATTRIBUTE_SUFFIX);
    //Get Attributes List
    StringTokenizer st = new StringTokenizer(attrList, COMMA);
    Map attributes = new HashMap();
    Set attributeValues = null;
    while (st.hasMoreTokens()) {
        attributeValues = new HashSet();
        String entry = st.nextToken();
        String attrName = entry.substring(0, entry.indexOf(EQUALS));
        String attrValue = entry.substring(entry.indexOf(EQUALS) + 1);
        attributeValues.add(attrValue);
        attributes.put(attrName, attributeValues);
    }
    clients.put(name, new Client(name, attributes));
    clientsData.put(name, attributes);
}
Also used : StringTokenizer(java.util.StringTokenizer) Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Client(com.iplanet.services.cdm.Client) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

Client (com.iplanet.services.cdm.Client)5 Set (java.util.Set)3 ClientException (com.iplanet.services.cdm.ClientException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 AttributeSchema (com.sun.identity.sm.AttributeSchema)1 Iterator (java.util.Iterator)1 StringTokenizer (java.util.StringTokenizer)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1