8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: DirectCOSDefinition.java,v 1.3 2008/06/25 05:41:47 qcheng Exp $
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington * Portions Copyrighted 2011-2015 ForgeRock AS.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunningtonimport org.forgerock.opendj.ldap.ModificationType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This class represents a Direct (or Classic) COS definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class DirectCOSDefinition extends PersistentObject implements
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * NoArg Constructor
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor with attribute set argument. The attribute set needs to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * contain all the required attributes for this definition: name,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * cosspecifier, cosattribute (with qualifier).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attrSet
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the attribute set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the DirectCOSDefinition constructor
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * accepting a creation template and attribute set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see com.iplanet.ums.cos.DirectCOSDefinition#DirectCOSDefinition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (CreationTemplate, AttrSet)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public DirectCOSDefinition(AttrSet attrSet) throws UMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this(TemplateManager.getTemplateManager().getCreationTemplate(_class,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor with creation template and attribute set arguments.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param template
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the Creation template.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attrSet
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the attribute set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the parent class constructor.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see com.iplanet.ums.PersistentObject#PersistentObject (CreationTemplate,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public DirectCOSDefinition(CreationTemplate template, AttrSet attrSet)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the name of this COS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the name of this COS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setAttribute(new Attr(ICOSDefinition.DEFAULT_NAMING_ATTR, name));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name of this COS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the name of this COS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Attr attribute = getAttribute(getNamingAttribute());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds the COS attribute to the definition. The COS attribute is the name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the attribute for which you want to generate a value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attrName
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The name of the attribute (for example, mailQuota)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param qualifier
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * An integer representing the following values: "default" - The
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * server only returns a generated value if there is no
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * corresponding attribute value stored with the entry.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "override" - This value will always be generated by the server
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (it will override entry values). "operational" - the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will only be returned if it is requested in the search.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "operational" can be combined with "default" or "override".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * These values are represented as integers in the ICOSDefinition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * interface.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addCOSAttribute(String attrName, int qualifier)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String msg = i18n.getString(IUMSConstants.BAD_COS_ATTR_QUALIFIER);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrStr.append(ICOSDefinition.qualifiers[qualifier]);
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington modify(ICOSDefinition.COSATTRIBUTE, attrStr.toString(), ModificationType.ADD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the COS attribute from the definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attrName
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The name of the attribute to be removed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeCOSAttribute(String attrName) {
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington modify(new Attr(ICOSDefinition.COSATTRIBUTE, attrName), ModificationType.DELETE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Retrieves the COS attributes for this definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return String[] A string array of COS attributes (for example,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * mailquota).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Attr attr = getAttribute(ICOSDefinition.COSATTRIBUTE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the COS specifier. The COS specifier is the attribute value used in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * conjunction with the template entry's DN, to identify the template entry.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param cosSpecifier
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The COS specifier.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setCOSSpecifier(String cosSpecifier) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setAttribute(new Attr(COSSPECIFIER, cosSpecifier));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the COS specifier.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the COS specifier
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see DirectCOSDefinition#setCOSSpecifier(String cosSpecifier)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds a COS Template to this COS definition. This COS definition must be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * persistent before adding the template.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param cosTemplate
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The COS Template to be added.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addCOSTemplate(COSTemplate cosTemplate) throws UMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getString(IUMSConstants.DEFINITION_NOT_PERSISTENT);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (getAttribute(ICOSDefinition.COSTEMPLATEDN) == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.modify(new Attr(ICOSDefinition.COSTEMPLATEDN, getGuid()
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes a COS Template from this COS definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The name of the template to be removed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeCOSTemplate(String name) throws UMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Guid tGuid = new Guid(COSTemplate.DEFAULT_NAMING_ATTR + "=" + name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes all COS Templates from this COS definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeCOSTemplates() throws UMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ArrayList aList = (ArrayList) getCOSTemplates();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster COSTemplate cosTemplate = (COSTemplate) aList.get(i);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a template from this definition given the name of the template.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The name of the template to be returned.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return The COS template.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws COSNotFoundException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown if the COS template is not found.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public COSTemplate getCOSTemplate(String name) throws COSNotFoundException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SearchResults sr = this.search("(" + COSTemplate.DEFAULT_NAMING_ATTR
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String msg = i18n.getString(IUMSConstants.COS_TEMPLATE_NOT_FOUND);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns all templates for this definition.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a collection of COS templates
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws UMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The exception thrown from the data layer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Collection getCOSTemplates() throws UMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SearchResults sr = this.search("(objectclass=costemplate)",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static I18n i18n = I18n.getInstance(IUMSConstants.UMS_PKG);