0001: /*
0002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
0003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
0004: */
0005:
0006: package com.sun.portal.providers;
0007:
0008: import java.io.File;
0009:
0010: import java.util.Map;
0011: import java.util.List;
0012: import java.util.ArrayList;
0013: import java.util.Vector;
0014: import java.util.Hashtable;
0015:
0016: import javax.servlet.http.HttpServletRequest;
0017: import javax.servlet.http.HttpServletResponse;
0018:
0019: import java.net.URL;
0020: import java.net.MalformedURLException;
0021:
0022: import com.sun.portal.desktop.template.TagSwapper;
0023:
0024: import com.sun.portal.providers.context.ProviderContext;
0025: import com.sun.portal.providers.context.ProviderContextException;
0026:
0027: import com.sun.portal.providers.ProviderException;
0028:
0029: /**
0030: * This class adds convenience wrappers around some commonly used
0031: * methods in the ProviderContext interface.<br><br>
0032: *
0033: * @see com.sun.portal.providers.Provider
0034: * @see com.sun.portal.providers.ProviderAdapter
0035: * @see com.sun.portal.providers.context.ProviderContext
0036: */
0037:
0038: public abstract class ProfileProviderAdapter extends ProviderAdapter {
0039:
0040: /**
0041: * Get a string property for the channel.
0042: *
0043: * <p>This method assumes that the property is defined.<br><br>
0044: *
0045: * @param key The key for the property to be returned.
0046: * @return The string value corresponding to the key.
0047: * @exception ProviderException if an error occurs in getting the
0048: * String property.
0049: */
0050: public String getStringProperty(String key)
0051: throws ProviderException {
0052: try {
0053: return getProviderContext().getStringProperty(getName(),
0054: key);
0055: } catch (ProviderContextException pce) {
0056: throw new ProviderException("ProfileProviderAdapter.(): ",
0057: pce);
0058: }
0059: }
0060:
0061: /**
0062: * Get a string property for the channel.
0063: *
0064: * <p>This method returns a
0065: * default value if the property does not exist.<br><br>
0066: *
0067: * @param key The key for the property to be returned.
0068: * @param def The default value to be returned if the property
0069: * does not exist.
0070: * @return The string value corresponding to the key.
0071: * @exception ProviderException if an error occurs in getting the
0072: * String property.
0073: */
0074: public String getStringProperty(String key, String def)
0075: throws ProviderException {
0076: try {
0077: return getProviderContext().getStringProperty(getName(),
0078: key, def);
0079: } catch (ProviderContextException pce) {
0080: throw new ProviderException("ProfileProviderAdapter.(): ",
0081: pce);
0082: }
0083: }
0084:
0085: /**
0086: * Get a filtered string property for the channel.
0087: *
0088: * <p>Filter criteria can be specified using a series of PropertiesFilter
0089: * objects. The order in that the PropertiesFilter objects are listed
0090: * determines the order that the property is searched.
0091: * If there is no property that exactly matches the filter criteria,
0092: * the best partial match is returned. When there is not even a
0093: * partial match, an unfiltered property is returned. <br><br>
0094: *
0095: * @param key The key for the property to be returned.
0096: * @param pflist An ordered list of PropertiesFilter objects
0097: * @return The string value corresponding to the key.
0098: * @exception ProviderException if an error occurs in getting the filtered
0099: * String property.
0100: *
0101: * @see PropertiesFilter
0102: */
0103:
0104: public String getStringProperty(String key, List pflist)
0105: throws ProviderException {
0106: try {
0107: return getProviderContext().getStringProperty(getName(),
0108: key, pflist);
0109: } catch (ProviderContextException pce) {
0110: throw new ProviderException("ProfileProviderAdapter.(): ",
0111: pce);
0112: }
0113: }
0114:
0115: /**
0116: * Get a filtered string property for the channel.
0117: *
0118: * <p>Filter criteria can be specified using a series of PropertiesFilter
0119: * objects. The order in that the PropertiesFilter objects are listed
0120: * determines the order that the property is searched.
0121: * If there is no property that exactly matches the filter criteria,
0122: * the best partial match is returned. When there is not even a
0123: * partial match, an unfiltered property is returned. If the unfiltered
0124: * property is unavailble, then the default value is returned.<br><br>
0125: *
0126: * @param key The key for the property to be returned.
0127: * @param def Default value.
0128: * @param pflist An ordered list of PropertiesFilter objects
0129: * @return The string value corresponding to the key.
0130: * @exception ProviderException if an error occurs in getting the filtered
0131: * String property.
0132: *
0133: * @see PropertiesFilter
0134: */
0135:
0136: public String getStringProperty(String key, String def, List pflist)
0137: throws ProviderException {
0138: try {
0139: return getProviderContext().getStringProperty(getName(),
0140: key, def, pflist);
0141: } catch (ProviderContextException pce) {
0142: throw new ProviderException("ProfileProviderAdapter.(): ",
0143: pce);
0144: }
0145: }
0146:
0147: /**
0148: * Get a localized string property for the channel.
0149: *
0150: * <p>If localized is true, then this method will attempt to find a localized
0151: * version of the string named by the key. The locale for the user
0152: * who this object is executing is read from the ProviderContext object
0153: * associated with this provider object. Locale-based strings are
0154: * searched for from more specific to less specific locales. For exmaple,
0155: * if the user locale was "en_US_SW",
0156: * the search order would be:<br><br>
0157: *
0158: * <ul>
0159: * <li>Look for string matching key under locale en_US_SW
0160: * <li>Look for string matching key under locale en_US
0161: * <li>Look for string matching key under locale en
0162: * <li>Look for non-locale specific key
0163: * </ul><br><br>
0164: *
0165: * This lookup order is the same as defined by Java resource bundles.<br><br>
0166: *
0167: * If a locale version of this string is not found, and a non-locale
0168: * version of this string is not found, then an <code>java.lang.Error</code> is thrown.
0169: * Client of this call can catch the error and provide code to handle the
0170: * error condition accordingly.<br><br>
0171: *
0172: * @param key The key for the property to be returned.
0173: * @param localized If true, first search for a localized string matching
0174: * the given key.
0175: * @return The string value corresponding to the key.
0176: * @exception ProviderException if an error occurs in getting the localized
0177: * String property.
0178: */
0179:
0180: public String getStringProperty(String key, boolean localized)
0181: throws ProviderException {
0182: try {
0183: return getProviderContext().getStringProperty(getName(),
0184: key, localized);
0185: } catch (ProviderContextException pce) {
0186: throw new ProviderException("ProfileProviderAdapter.(): ",
0187: pce);
0188: }
0189: }
0190:
0191: /**
0192: * Get a localized string property for the channel.
0193: *
0194: * <p>If localized is true, then this method will attempt to find a localized
0195: * version of the string named by the key. The locale for the user
0196: * who this object is executing is read from the ProviderContext object
0197: * associated with this provider object. Locale-based strings are
0198: * searched for from more specific to less specific locales. For exmaple,
0199: * if the user locale was "en_US_SW",
0200: * the search order would be:<br><br>
0201: *
0202: * <ul>
0203: * <li>Look for string matching key under locale en_US_SW
0204: * <li>Look for string matching key under locale en_US
0205: * <li>Look for string matching key under locale en
0206: * <li>Look for non-locale specific key
0207: * </ul><br><br>
0208: *
0209: * This lookup order is the same as defined by Java resource bundles.
0210: *
0211: * If a locale version of this string is not found, and a non-locale
0212: * version of this string is not found, then this method returns a
0213: * default value.<br><br>
0214: *
0215: * @param key The key for the property to be returned.
0216: * @param def Default value.
0217: * @param localized If true, first search for a localized string matching
0218: * the given key.
0219: * @return The string value corresponding to the key.
0220: * @exception ProviderException if an error occurs in getting the localized
0221: * String property.
0222: */
0223:
0224: public String getStringProperty(String key, String def,
0225: boolean localized) throws ProviderException {
0226: try {
0227: return getProviderContext().getStringProperty(getName(),
0228: key, def, localized);
0229: } catch (ProviderContextException pce) {
0230: throw new ProviderException("ProfileProviderAdapter.(): ",
0231: pce);
0232: }
0233: }
0234:
0235: /**
0236: * Get a list property for the channel.
0237: *
0238: * <p>This method assumes that the property is defined.<br><br>
0239: *
0240: * @param key The key for the property to be returned.
0241: * @return The list value corresponding to the key.
0242: */
0243: public List getListProperty(String key) throws ProviderException {
0244: try {
0245: return new ArrayList(getProviderContext()
0246: .getCollectionProperty(getName(), key).values());
0247: } catch (ProviderContextException pce) {
0248: throw new ProviderException("ProfileProviderAdapter.(): ",
0249: pce);
0250: }
0251: }
0252:
0253: /**
0254: * Get a list property for the provider.
0255: *
0256: * <p>This method will return the defaule list passed in if the
0257: * property is undefined for the channel.<br><br>
0258: *
0259: * @param key The key for the property to be returned.
0260: * @param def The default list to be returned if the property
0261: * does not exist.
0262: * @return The list value corresponding to the key.
0263: */
0264: public List getListProperty(String key, List def)
0265: throws ProviderException {
0266: try {
0267: if (!existsListProperty(key)) {
0268: return def;
0269: }
0270:
0271: return new ArrayList(getProviderContext()
0272: .getCollectionProperty(getName(), key).values());
0273: } catch (ProviderContextException pce) {
0274: throw new ProviderException("ProfileProviderAdapter.(): ",
0275: pce);
0276: }
0277: }
0278:
0279: /**
0280: * Get a map property for the channel.
0281: * <p/>
0282: * <p>This method assumes that the property is defined.<br><br>
0283: * <p/>
0284: * The Java <code>Map</code> object returned from this method
0285: * does not fronts the persistent store for the property.
0286: * Changes to the return value are not persisted.
0287: * Changes must be persisted with
0288: * <code>setMapProperty()</code> call. For example, <br><br>
0289: * <code>
0290: * Map m = p.getMapProperty("foo");<br>
0291: * m.put("a", "1");<br>
0292: * p.setMapProperty("foo", m);<br><br>
0293: * </code>
0294: *
0295: * @param key The key for the property to be returned.
0296: * @return The map value corresponding to the key.
0297: */
0298: public Map getMapProperty(String key) throws ProviderException {
0299: try {
0300: return getProviderContext().getCollectionProperty(
0301: getName(), key);
0302: } catch (ProviderContextException pce) {
0303: throw new ProviderException("ProfileProviderAdapter.(): ",
0304: pce);
0305: }
0306: }
0307:
0308: /**
0309: * Get the filtered map property for the channel.
0310: *
0311: * <p>Filter criteria can be specified using a series of PropertiesFilter
0312: * objects. The order in that the PropertiesFilter objects are listed
0313: * determines the order that the property is searched.
0314: * If there is no property that exactly matches the filter criteria,
0315: * the best partial match is returned. When there is not even a
0316: * partial match, an unfiltered property is returned. If the unfiltered
0317: * property is unavailble, then the default value is returned.<br><br>
0318: *
0319: * @param key The key for the property to be returned.
0320: * @param pflist An ordered list of PropertiesFilter objects.
0321: * @return The map value corresponding to the key and the filters.
0322: *
0323: * @see PropertiesFilter
0324: */
0325:
0326: public Map getMapProperty(String key, List pflist)
0327: throws ProviderException {
0328: try {
0329: return getProviderContext().getCollectionProperty(
0330: getName(), key, pflist);
0331: } catch (ProviderContextException pce) {
0332: throw new ProviderException("ProfileProviderAdapter.(): ",
0333: pce);
0334: }
0335: }
0336:
0337: /**
0338: * Get the localized version of a map property for the channel.
0339: *
0340: * <p>If localized is true, then this method will attempt to find a localized
0341: * version of the map named by the key. The locale for the user
0342: * who this object is executing is read from the ProviderContext object
0343: * associated with this providero object. Locale-based maps are
0344: * searched for from more specific to less specific locales. For exmaple,
0345: * if the user locale was "en_US_SW",
0346: * the search order would be:<br><br>
0347: *
0348: * <ul>
0349: * <li>Look for map matching key under locale en_US_SW
0350: * <li>Look for map matching key under locale en_US
0351: * <li>Look for map matching key under locale en
0352: * <li>Look for non-locale specific key
0353: * </ul><br><br>
0354: *
0355: * This lookup order is the same as defined by Java resource bundles.<br><br>
0356: *
0357: * If a locale version of this map is not found, and a non-locale
0358: * version of this map is not found, then an <code>java.lang.Error</code> is thrown.
0359: * Client of this call can catch the error and provide code to handle the
0360: * error condition accordingly.<br><br>
0361: *
0362: * @param key The key for the property to be returned.
0363: * @param localized If true, first search for a localized map matching
0364: * the given key.
0365: * @return The map value corresponding to the key.
0366: */
0367: public Map getMapProperty(String key, boolean localized)
0368: throws ProviderException {
0369: try {
0370: return getProviderContext().getCollectionProperty(
0371: getName(), key, localized);
0372: } catch (ProviderContextException pce) {
0373: throw new ProviderException("ProfileProviderAdapter.(): ",
0374: pce);
0375: }
0376: }
0377:
0378: /**
0379: * Get a map property for the channel.
0380: *
0381: * <p>This method returns a default
0382: * value if the property does not exist.<br><br>
0383: *
0384: * This method assumes that the property is defined.<br><br>
0385: *
0386: * @param key The key for the property to be returned.
0387: * @param def Default value.
0388: * @return The map value corresponding to the key.
0389: */
0390: public Map getMapProperty(String key, Map def)
0391: throws ProviderException {
0392: try {
0393: return getProviderContext().getCollectionProperty(
0394: getName(), key, def);
0395: } catch (ProviderContextException pce) {
0396: throw new ProviderException("ProfileProviderAdapter.(): ",
0397: pce);
0398: }
0399: }
0400:
0401: /**
0402: * Get the filtered map property for the channel.
0403: *
0404: * <p>Filter criteria can be specified using a series of PropertiesFilter
0405: * objects. The order in that the PropertiesFilter objects are listed
0406: * determines the order that the property is searched.
0407: * If there is no property that exactly matches the filter criteria,
0408: * the best partial match is returned. When there is not even a
0409: * partial match, an unfiltered property is returned. If the unfiltered
0410: * property is unavailble, then the default value is returned.<br><br>
0411: *
0412: * @param key The key for the property to be returned.
0413: * @param def Default value.
0414: * @param pflist An ordered list of PropertiesFilter objects
0415: * @return The map value corresponding to the key and the filters.
0416: *
0417: * @see PropertiesFilter
0418: */
0419:
0420: public Map getMapProperty(String key, Map def, List pflist)
0421: throws ProviderException {
0422: try {
0423: return getProviderContext().getCollectionProperty(
0424: getName(), key, def, pflist);
0425: } catch (ProviderContextException pce) {
0426: throw new ProviderException("ProfileProviderAdapter.(): ",
0427: pce);
0428: }
0429: }
0430:
0431: /**
0432: * Get the localized version of a map property for the channel.
0433: *
0434: * <p>If localized is true, then this method will attempt to find a localized
0435: * version of the map named by the key. The locale for the user
0436: * who this object is executing is read from the ProviderContext object
0437: * associated with this providero object. Locale-based maps are
0438: * searched for from more specific to less specific locales. For exmaple,
0439: * if the user locale was "en_US_SW",
0440: * the search order would be:<br><br>
0441: *
0442: * <ul>
0443: * <li>Look for map matching key under locale en_US_SW
0444: * <li>Look for map matching key under locale en_US
0445: * <li>Look for map matching key under locale en
0446: * <li>Look for non-locale specific key
0447: * </ul><br><br>
0448: *
0449: * This lookup order is the same as defined by Java resource bundles.<br><br>
0450: *
0451: * If a locale version of this map is not found, and a non-locale
0452: * version of this string is not found, then this method returns a
0453: * default value.<br><br>
0454: *
0455: * @param key The key for the property to be returned.
0456: * @param def Default value.
0457: * @param localized If true, first search for a localized map matching
0458: * the given key.
0459: * @return The map value corresponding to the key.
0460: */
0461: public Map getMapProperty(String key, Map def, boolean localized)
0462: throws ProviderException {
0463: try {
0464: return getProviderContext().getCollectionProperty(
0465: getName(), key, def, localized);
0466: } catch (ProviderContextException pce) {
0467: throw new ProviderException("ProfileProviderAdapter.(): ",
0468: pce);
0469: }
0470: }
0471:
0472: /**
0473: * Get a boolean property for the channel.
0474: *
0475: * <p>This method assumes that the property is defined.<br><br>
0476: *
0477: * @param key The key for the property to be returned.
0478: * @return The boolean value corresponding to the key.
0479: */
0480: public boolean getBooleanProperty(String key)
0481: throws ProviderException {
0482: try {
0483: return getProviderContext().getBooleanProperty(getName(),
0484: key);
0485: } catch (ProviderContextException pce) {
0486: throw new ProviderException("ProfileProviderAdapter.(): ",
0487: pce);
0488: }
0489: }
0490:
0491: /**
0492: * Get the filtered boolean property for the channel.
0493: *
0494: * <p>This method assumes that the property is defined.<br><br>
0495: * <p>Filter criteria can be specified using a series of PropertiesFilter
0496: * objects. The order in that the PropertiesFilter objects are listed
0497: * determines the order that the property is searched.
0498: * If there is no property that exactly matches the filter criteria,
0499: * the best partial match is returned. When there is not even a
0500: * partial match, an unfiltered property is returned. If the unfiltered
0501: * property is unavailble, then the default value is returned.<br><br>
0502: *
0503: * @param key The key for the property to be returned.
0504: * @param pflist An ordered list of PropertiesFilter objects
0505: * @return The boolean value corresponding to the key.
0506: */
0507: public boolean getBooleanProperty(String key, List pflist)
0508: throws ProviderException {
0509: try {
0510: return getProviderContext().getBooleanProperty(getName(),
0511: key, pflist);
0512: } catch (ProviderContextException pce) {
0513: throw new ProviderException("ProfileProviderAdapter.(): ",
0514: pce);
0515: }
0516: }
0517:
0518: /**
0519: * Get a boolean property for the channel.
0520: *
0521: * <p>This method returns a default
0522: * value if the property does not exist.<br><br>
0523: *
0524: * @param key The key for the property to be returned.
0525: * @param def Default value.
0526: * @return The boolean value corresponding to the key.
0527: */
0528: public boolean getBooleanProperty(String key, boolean def)
0529: throws ProviderException {
0530: try {
0531: return getProviderContext().getBooleanProperty(getName(),
0532: key, def);
0533: } catch (ProviderContextException pce) {
0534: throw new ProviderException("ProfileProviderAdapter.(): ",
0535: pce);
0536: }
0537: }
0538:
0539: /**
0540: * Get the filtered boolean property for the channel.
0541: *
0542: * <p>This method returns a default
0543: * value if the property does not exist.<br><br>
0544: * <p>Filter criteria can be specified using a series of PropertiesFilter
0545: * objects. The order in that the PropertiesFilter objects are listed
0546: * determines the order that the property is searched.
0547: * If there is no property that exactly matches the filter criteria,
0548: * the best partial match is returned. When there is not even a
0549: * partial match, an unfiltered property is returned. If the unfiltered
0550: * property is unavailble, then the default value is returned.<br><br>
0551: *
0552: * @param key The key for the property to be returned.
0553: * @param def Default value.
0554: * @param pflist An ordered list of PropertiesFilter objects
0555: * @return The boolean value corresponding to the key.
0556: */
0557: public boolean getBooleanProperty(String key, boolean def,
0558: List pflist) throws ProviderException {
0559: try {
0560: return getProviderContext().getBooleanProperty(getName(),
0561: key, def, pflist);
0562: } catch (ProviderContextException pce) {
0563: throw new ProviderException("ProfileProviderAdapter.(): ",
0564: pce);
0565: }
0566: }
0567:
0568: /**
0569: * Get an integer property for the channel.
0570: *
0571: * <p>This method assumes that the property is defined.<br><br>
0572: *
0573: * @param key The key for the property to be returned.
0574: * @return The integer value corresponding to the key.
0575: */
0576: public int getIntegerProperty(String key) throws ProviderException {
0577: try {
0578: return getProviderContext().getIntegerProperty(getName(),
0579: key);
0580: } catch (ProviderContextException pce) {
0581: throw new ProviderException("ProfileProviderAdapter.(): ",
0582: pce);
0583: }
0584: }
0585:
0586: /**
0587: * Get an integer property for the channel.
0588: *
0589: * <p>This method assumes that the property is defined.<br><br>
0590: * <p>Filter criteria can be specified using a series of PropertiesFilter
0591: * objects. The order in that the PropertiesFilter objects are listed
0592: * determines the order that the property is searched.
0593: * If there is no property that exactly matches the filter criteria,
0594: * the best partial match is returned. When there is not even a
0595: * partial match, an unfiltered property is returned. If the unfiltered
0596: * property is unavailble, then the default value is returned.<br><br>
0597: *
0598: * @param key The key for the property to be returned.
0599: * @param pflist An ordered list of PropertiesFilter objects
0600: * @return The integer value corresponding to the key.
0601: */
0602: public int getIntegerProperty(String key, List pflist)
0603: throws ProviderException {
0604: try {
0605: return getProviderContext().getIntegerProperty(getName(),
0606: key, pflist);
0607: } catch (ProviderContextException pce) {
0608: throw new ProviderException("ProfileProviderAdapter.(): ",
0609: pce);
0610: }
0611: }
0612:
0613: /**
0614: * Get an integer property for the channel.
0615: *
0616: * <p>This method returns a default
0617: * value if the property does not exist.<br><br>
0618: *
0619: * @param key The key for the property to be returned.
0620: * @param def Default value.
0621: * @return The integer value corresponding to the key.
0622: */
0623: public int getIntegerProperty(String key, int def)
0624: throws ProviderException {
0625: try {
0626: return getProviderContext().getIntegerProperty(getName(),
0627: key, def);
0628: } catch (ProviderContextException pce) {
0629: throw new ProviderException("ProfileProviderAdapter.(): ",
0630: pce);
0631: }
0632: }
0633:
0634: /**
0635: * Get an integer property for the channel.
0636: *
0637: * <p>This method returns a default
0638: * value if the property does not exist.<br><br>
0639: * <p>Filter criteria can be specified using a series of PropertiesFilter
0640: * objects. The order in that the PropertiesFilter objects are listed
0641: * determines the order that the property is searched.
0642: * If there is no property that exactly matches the filter criteria,
0643: * the best partial match is returned. When there is not even a
0644: * partial match, an unfiltered property is returned. If the unfiltered
0645: * property is unavailble, then the default value is returned.<br><br>
0646: *
0647: * @param key The key for the property to be returned.
0648: * @param def Default value.
0649: * @param pflist An ordered list of PropertiesFilter objects
0650: * @return The integer value corresponding to the key.
0651: */
0652: public int getIntegerProperty(String key, int def, List pflist)
0653: throws ProviderException {
0654: try {
0655: return getProviderContext().getIntegerProperty(getName(),
0656: key, def, pflist);
0657: } catch (ProviderContextException pce) {
0658: throw new ProviderException("ProfileProviderAdapter.(): ",
0659: pce);
0660: }
0661: }
0662:
0663: /**
0664: * Get a string attribute.
0665: *
0666: * <p>"Attributes" are settings that are not
0667: * channel-specific. An example of an attribute might be the user's
0668: * first and last name. Channel-specific settings are called
0669: * "properties". <br><br>
0670: * Properties can be retrieved by calling the
0671: * <code>get*Property()</code> methods.
0672: * Whether
0673: * a particular value is considered a property or an attribute depends
0674: * on the underlying implementation of <code>ProviderContext</code>.<br><br>
0675: *
0676: * @param name Attribute name.
0677: * @return Attribute value as a string. If attribute is
0678: * not not found, null is returned.
0679: */
0680: public String getStringAttribute(String name) {
0681: return getProviderContext().getStringAttribute(name);
0682: }
0683:
0684: /**
0685: * Get the client property.
0686: *
0687: * @param name Property name.
0688: * @return Property value. If the property is
0689: * not not found, then null is returned.
0690: */
0691: public String getClientProperty(String name) {
0692: return getProviderContext().getClientProperty(name);
0693: }
0694:
0695: /**
0696: * Checks for access to the named privilege.
0697: *
0698: * <p>This method is provided for backwards compatibility. There is
0699: * no longer a concept of a privilege in the Provider API. Instead, use
0700: * boolean properties.<br><br>
0701: *
0702: * This method simply calls getBooleanProperty() to determine its
0703: * return value.<br><br>
0704: *
0705: * @param priv The privilege to check.
0706: * @return A <code>boolean</code> value. <code>true</code> if the user is granted access by the named
0707: * privilege, otherwise <code>false</code>.
0708: * @deprecated use getBooleanProperty()
0709: */
0710: public boolean isAllowed(String priv) throws ProviderException {
0711: return getBooleanProperty(priv);
0712: }
0713:
0714: /**
0715: * Sets a string property for the channel.
0716: *
0717: * <p>This method assumes that the property is defined.<br><br>
0718: *
0719: * @param key The key for the property to be set.
0720: * @param val The value for the propery to be set.
0721: * @return The previous value.
0722: */
0723: public String setStringProperty(String key, String val)
0724: throws ProviderException {
0725: try {
0726: String orig = getProviderContext().getStringProperty(
0727: getName(), key);
0728: getProviderContext().setStringProperty(getName(), key, val);
0729:
0730: return orig;
0731: } catch (ProviderContextException pce) {
0732: throw new ProviderException("ProfileProviderAdapter.(): ",
0733: pce);
0734: }
0735: }
0736:
0737: /**
0738: * Sets a list property for the channel.
0739: *
0740: * <p>This method assumes that the property is defined.<br><br>
0741: *
0742: * @param key The key for the property to be set.
0743: * @param val The value for the propery to be set.
0744: * @return The previous value.
0745: */
0746: public List setListProperty(String key, List val)
0747: throws ProviderException {
0748: try {
0749: List orig = new ArrayList(getProviderContext()
0750: .getCollectionProperty(getName(), key).values());
0751: getProviderContext().setCollectionProperty(getName(), key,
0752: val);
0753:
0754: return orig;
0755: } catch (ProviderContextException pce) {
0756: throw new ProviderException("ProfileProviderAdapter.(): ",
0757: pce);
0758: }
0759: }
0760:
0761: /**
0762: * Sets a map property for the channel.
0763: *
0764: * <p>This method assumes that the property is defined.<br><br>
0765: *
0766: * @param key The key for the property to be set.
0767: * @param val The value for the propery to be set.
0768: * @return The previous value.
0769: */
0770: public Map setMapProperty(String key, Map val)
0771: throws ProviderException {
0772: try {
0773: Map orig = getProviderContext().getCollectionProperty(
0774: getName(), key);
0775: getProviderContext().setCollectionProperty(getName(), key,
0776: val);
0777:
0778: return orig;
0779: } catch (ProviderContextException pce) {
0780: throw new ProviderException("ProfileProviderAdapter.(): ",
0781: pce);
0782: }
0783: }
0784:
0785: /**
0786: * Sets a boolean property for the channel.
0787: *
0788: * <p>This method assumes that the property is defined.<br><br>
0789: *
0790: * @param key The key for the property to be set.
0791: * @param val The value for the propery to be set.
0792: * @return The previous value.
0793: */
0794: public boolean setBooleanProperty(String key, boolean val)
0795: throws ProviderException {
0796: try {
0797: boolean orig = getProviderContext().getBooleanProperty(
0798: getName(), key);
0799: getProviderContext()
0800: .setBooleanProperty(getName(), key, val);
0801: return orig;
0802: } catch (ProviderContextException pce) {
0803: throw new ProviderException("ProfileProviderAdapter.(): ",
0804: pce);
0805: }
0806: }
0807:
0808: /**
0809: * Sets a integer property for the channel.
0810: *
0811: * <p>This method assumes that the property is defined.<br><br>
0812: *
0813: * @param key The key for the property to be set.
0814: * @param val The value for the propery to be set.
0815: * @return The previous value.
0816: */
0817: public int setIntegerProperty(String key, int val)
0818: throws ProviderException {
0819: try {
0820: int orig = getProviderContext().getIntegerProperty(
0821: getName(), key);
0822: getProviderContext()
0823: .setIntegerProperty(getName(), key, val);
0824: return orig;
0825: } catch (ProviderContextException pce) {
0826: throw new ProviderException("ProfileProviderAdapter.(): ",
0827: pce);
0828: }
0829: }
0830:
0831: /**
0832: * Sets a string attribute.
0833: *
0834: * <p>"Attributes" are settings that are not
0835: * channel-specific. An example of an attribute might be the user's
0836: * first and last name. Channel-specific settings are called
0837: * "properties". <br><br>
0838: * Properties can be set by calling the
0839: * <code>set*Property()</code> methods.
0840: * Whether
0841: * a particular value is considered a property or an attribute depends
0842: * on the underlying implementation of <code>ProviderContext</code>.<br><br>
0843: *
0844: * @param name Attribute name.
0845: * @param name Attribute value.
0846: */
0847: public void setStringAttribute(String name, String val) {
0848: getProviderContext().setStringAttribute(name, val);
0849: }
0850:
0851: /**
0852: * Sets a client property.
0853: *
0854: * @param name The property name.
0855: * @param value The property value.
0856: */
0857: public void setClientProperty(String name, String val) {
0858: getProviderContext().setClientProperty(name, val);
0859: }
0860:
0861: /**
0862: * Tests for the existence of a string property in the channel.
0863: *
0864: * @param name A <code>String</code>, the property name.
0865: * @return A <code>boolean</code>, <code>true</code> if the
0866: * property exists, otherwise <code>false</code>.
0867: */
0868: public boolean existsStringProperty(String name)
0869: throws ProviderException {
0870: try {
0871: return getProviderContext().existsStringProperty(getName(),
0872: name);
0873: } catch (ProviderContextException pce) {
0874: throw new ProviderException("ProfileProviderAdapter.(): ",
0875: pce);
0876: }
0877: }
0878:
0879: /**
0880: * Tests for the existence of a string property in the channel.
0881: *
0882: * <p>This method will also check for the existence of the localized
0883: * version of the property.<br><br>
0884: *
0885: * @param name A <code>String</code>, the property name.
0886: * @param localized A <code>boolean</code>, whether to check the
0887: * existence of localized properties.
0888: *
0889: * @return A <code>boolean</code>, <code>true</code> if the
0890: * property exists, otherwise <code>false</code>.
0891: */
0892: public boolean existsStringProperty(String name, boolean localized)
0893: throws ProviderException {
0894: try {
0895: return getProviderContext().existsStringProperty(getName(),
0896: name, localized);
0897: } catch (ProviderContextException pce) {
0898: throw new ProviderException("ProfileProviderAdapter.(): ",
0899: pce);
0900: }
0901: }
0902:
0903: /**
0904: * Tests for the existence of a boolean property in the channel.
0905: *
0906: * @param name A <code>String</code>, the property name.
0907: * @return A <code>boolean</code>, <code>true</code> if the
0908: * property exists, otherwise <code>false</code>.
0909: */
0910: public boolean existsBooleanProperty(String name)
0911: throws ProviderException {
0912: try {
0913: return getProviderContext().existsBooleanProperty(
0914: getName(), name);
0915: } catch (ProviderContextException pce) {
0916: throw new ProviderException("ProfileProviderAdapter.(): ",
0917: pce);
0918: }
0919: }
0920:
0921: /**
0922: * Tests for the existence of an integer property in the channel.
0923: *
0924: * @param name A <code>String</code>, the property name.
0925: * @return A <code>boolean</code>, <code>true</code> if the
0926: * property exists, otherwise <code>false</code>.
0927: */
0928: public boolean existsIntegerProperty(String name)
0929: throws ProviderException {
0930: try {
0931: return getProviderContext().existsIntegerProperty(
0932: getName(), name);
0933: } catch (ProviderContextException pce) {
0934: throw new ProviderException("ProfileProviderAdapter.(): ",
0935: pce);
0936: }
0937: }
0938:
0939: /**
0940: * Tests for the existence of a list property in the channel.
0941: *
0942: * @param name A <code>String</code>, the property name.
0943: * @return A <code>boolean</code>, <code>true</code> if the
0944: * property exists, otherwise <code>false</code>.
0945: */
0946: public boolean existsListProperty(String name)
0947: throws ProviderException {
0948: try {
0949: return getProviderContext().existsCollectionProperty(
0950: getName(), name);
0951: } catch (ProviderContextException pce) {
0952: throw new ProviderException("ProfileProviderAdapter.(): ",
0953: pce);
0954: }
0955: }
0956:
0957: /**
0958: * Tests for the existence of a listproperty in the channel.
0959: *
0960: * <p>This method will also check for the existence of the localized
0961: * version of the property.<br><br>
0962: *
0963: * @param name A <code>String</code>, the property name.
0964: * @param localized A <code>boolean</code>, whether to check the
0965: * existence of localized properties.
0966: * @return A <code>boolean</code>, <code>true</code> if the
0967: * property exists, otherwise <code>false</code>.
0968: */
0969: public boolean existsListProperty(String name, boolean localized)
0970: throws ProviderException {
0971: try {
0972: return getProviderContext().existsCollectionProperty(
0973: getName(), name, localized);
0974: } catch (ProviderContextException pce) {
0975: throw new ProviderException("ProfileProviderAdapter.(): ",
0976: pce);
0977: }
0978: }
0979:
0980: /**
0981: * <P>Get template for the provider.
0982: *
0983: * <P>The directory search order of the template file is as
0984: * follows:
0985: * <ul>
0986: * <li><type>_<locale>/<component>/<clientPath>
0987: * <li><type>_<locale>/<component>
0988: * <li><type>_<locale>/<clientPath>
0989: * <li><type>_<locale>
0990: * <li><type>/<component>/<clientPath>
0991: * <li><type>/<component>
0992: * <li><type>
0993: * <li>default_<locale>/<component>/<clientPath>
0994: * <li>default_<locale>/<component>
0995: * <li>default_<locale>
0996: * <li>default/<component>/<clientPath>
0997: * <li>default/<component>
0998: * <li>default/<clientPath>
0999: * <li>default
1000: * </ul>
1001: * <P>Where
1002: * <ol>
1003: * <li><type> is the value of the desktop template type property
1004: * <li><locale> is the user's locale
1005: * <li><component> is the component name (or channel name)
1006: * <li><clientPath> is an optional file-path containing client-specific
1007: * templates
1008: * </ol>
1009: *
1010: * <p>If there is no <clientPath> specified, then the directory search
1011: * order is as follows:
1012: * <ul>
1013: * <li><type>_<locale>/<component>
1014: * <li><type>_<locale>
1015: * <li><type>/<component>
1016: * <li><type>
1017: * <li>default_<locale>/<component>
1018: * <li>default_<locale>
1019: * <li>default/<component>
1020: * <li>default
1021: * </ul><br><br>
1022: *
1023: * @param file The template file name
1024: * @return template A <code>StringBuffer</code> represents the template
1025: */
1026: public StringBuffer getTemplate(String file)
1027: throws ProviderException {
1028: try {
1029: return getProviderContext().getTemplate(getName(), file);
1030: } catch (ProviderContextException pce) {
1031: throw new ProviderException("ProfileProviderAdapter.(): ",
1032: pce);
1033: }
1034: }
1035:
1036: /**
1037: * <P>Get the template path for the given channel name and the given
1038: * template name. If non-null, the key returned by this method will map to a
1039: * most specific, existing template file. The format of the returned path
1040: * is implementation dependent.
1041: *
1042: * @see #getTemplate(String)
1043: */
1044: public File getTemplatePath(String file) throws ProviderException {
1045: try {
1046: return getProviderContext()
1047: .getTemplatePath(getName(), file);
1048: } catch (ProviderContextException pce) {
1049: throw new ProviderException("ProfileProviderAdapter.(): ",
1050: pce);
1051: }
1052: }
1053:
1054: /**
1055: * <P>Get template for the provider, and tag swap the results before
1056: * returning.
1057: *
1058: * @see #getTemplate(String)
1059: */
1060: public StringBuffer getTemplate(String file, Hashtable table)
1061: throws ProviderException {
1062: try {
1063: return getProviderContext().getTemplate(getName(), file,
1064: table);
1065: } catch (ProviderContextException pce) {
1066: throw new ProviderException("ProfileProviderAdapter.(): ",
1067: pce);
1068: }
1069: }
1070:
1071: }
|