001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: COSTemplate.java,v 1.4 2008/06/25 05:41:47 qcheng Exp $ 026 * 027 */ 028 029package com.iplanet.ums.cos; 030 031import com.iplanet.services.ldap.Attr; 032import com.iplanet.services.ldap.AttrSet; 033import com.iplanet.services.ldap.ModSet; 034import com.iplanet.ums.CreationTemplate; 035import com.iplanet.ums.PersistentObject; 036import com.iplanet.ums.UMSException; 037 038/** 039 * This class represents a COS Template. A COS Template has attributes and 040 * attribute values which will be dynamically added to entries affected by COS 041 * definitions. 042 * @supported.api 043 */ 044public class COSTemplate extends PersistentObject { 045 046 /** 047 * NoArg constructor 048 */ 049 public COSTemplate() { 050 } 051 052 /** 053 * Constructor with creation template and name parameter. 054 * 055 * @param temp 056 * the creation tenplate 057 * @param name 058 * the name of this template 059 * 060 * @throws UMSException 061 * The exception thrown from the parent class constructor. 062 * @see com.iplanet.ums.PersistentObject#PersistentObject (CreationTemplate, 063 * AttrSet) 064 * @supported.api 065 */ 066 public COSTemplate(CreationTemplate temp, String name) throws UMSException { 067 super(temp, 068 new AttrSet(new Attr(COSTemplate.DEFAULT_NAMING_ATTR, name))); 069 } 070 071 /** 072 * Returns the name of this COS template. 073 * 074 * @return The name of this COS template. 075 * @supported.api 076 */ 077 public String getName() { 078 String attributeValue = null; 079 Attr attribute = getAttribute(getNamingAttribute()); 080 if (attribute != null) { 081 attributeValue = attribute.getValue(); 082 } 083 return attributeValue; 084 } 085 086 /** 087 * Sets the priority for this template. The priority determines which COS 088 * template will provide the attribute value if there are competing 089 * templates. A priority of "0" is the highest priority. 090 * 091 * @param priority Priority for this template. 092 * @supported.api 093 */ 094 public void setPriority(int priority) { 095 setAttribute(new Attr("cosPriority", new Integer(priority).toString())); 096 } 097 098 /** 099 * Adds a name/value attribute pair for this template; for example, 100 * "postalcode" and "95020". 101 * 102 * @param name 103 * the name of the attribute 104 * 105 * @param value 106 * the value of the attribute 107 * @supported.api 108 */ 109 public void addTemplateAttribute(String name, String value) { 110 modify(name, value, ModSet.ADD); 111 } 112 113 /** 114 * Removes a name/value attribute pair from this template. 115 * 116 * @param name 117 * the name of the attribute 118 * @supported.api 119 */ 120 public void removeTemplateAttribute(String name) { 121 removeAttribute(new Attr(name)); 122 } 123 124 /** 125 * LDAP attribute names that apply to COS LDAP entries; used internally by 126 * UMS and COS Manager. 127 */ 128 static final String DEFAULT_NAMING_ATTR = "cn"; 129 130 static final String[] ATTRIBUTE_NAMES = { "objectclass", 131 DEFAULT_NAMING_ATTR }; 132 133}
Copyright © 2010-2017, ForgeRock All Rights Reserved.