com.sapportals.wcm.rfadapter

Class IDResolver

java.lang.Object
  extended by com.sapportals.wcm.rfadapter.IDResolver

public final class IDResolver
extends Object

offers functionality to calculate valid (and unique) IDs from a String that can be used to create IResource objects within a certain ICollection. To ensure the validity of the calculated IDs, the class uses the NameInfo class of the RepositoryFramework for a list of char that are forbidden. This class is implemented as a singleton. It uses the IDValidator class to check for invalid characters, while the check for uniqueness within a folder is done in this class. Note that uniqueness within a folder cannot be guaranteed, because the current user might not have the permission to see all elements within the current ICollection.

Since:
EP6, FP3

Nested Class Summary
 class IDResolver.IDProposal
          an immutable object containing all information about the id generation.
static class IDResolver.Status
           
 
Field Summary
static IDResolver.Status INVALID
           
static IDResolver.Status NON_UNIQUE
           
static char NUMERATOR
           
static char NUMERATOR_PREFIX
           
static char NUMERATOR_SUFFIX
           
static char REPLACER
           
static IDResolver.Status UNIQUE
           
 
Method Summary
 IDResolver.Status checkID(String id, ICollection targetfolder)
          checks if the given id would be a valid id within the given folder.
 IDResolver.IDProposal generateID(String displayname, ICollection targetfolder)
          generates an ID proposal based on the given displayname that is valid within the given targetfolder.
 List generateIDs(List displaynames, ICollection targetfolder)
          generates ID proposals based on the list with displaynames that are valid within the given targetfolder.
static IDResolver getInstance()
           
 String getInvalidChars()
           
 char[] invalidChars()
           
 boolean isValidID(String id)
          decides if the given parameter would be a valid id for an IResource.
 String normalizeID(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIQUE

public static final IDResolver.Status UNIQUE

INVALID

public static final IDResolver.Status INVALID

NON_UNIQUE

public static final IDResolver.Status NON_UNIQUE

REPLACER

public static final char REPLACER
See Also:
Constant Field Values

NUMERATOR

public static final char NUMERATOR
See Also:
Constant Field Values

NUMERATOR_SUFFIX

public static final char NUMERATOR_SUFFIX
See Also:
Constant Field Values

NUMERATOR_PREFIX

public static final char NUMERATOR_PREFIX
See Also:
Constant Field Values
Method Detail

invalidChars

public char[] invalidChars()

getInvalidChars

public String getInvalidChars()

getInstance

public static IDResolver getInstance()

isValidID

public boolean isValidID(String id)
decides if the given parameter would be a valid id for an IResource. It will throw a NullPointerException, if the parameter is null

Parameters:
id - the id to test, must not be null
Returns:
true, if the id would be a valid ID, false otherwise

checkID

public IDResolver.Status checkID(String id,
                                 ICollection targetfolder)
                          throws WcmException
checks if the given id would be a valid id within the given folder. In comparison to the method isValidID it also checks, if the id would be unique within the folder. If one of the parameters is null, a NullPointerException will be thrown

Parameters:
id - the proposed id for the IResource
targetfolder - the folder in which to create the IResource
Returns:
a status declaring, if the given id is a valid id, a unique id within the given folder or a invalid id.
Throws:
a - WcmException when operations on the given collection fail
WcmException

normalizeID

public String normalizeID(String id)

generateID

public IDResolver.IDProposal generateID(String displayname,
                                        ICollection targetfolder)
                                 throws WcmException
generates an ID proposal based on the given displayname that is valid within the given targetfolder. The returned class contains the proposed id and will give further information why and how the proposed id differs from the given displayname. When creating a new IResource in the given ICollection using the ID generated by this method, you might still run into a NameAlreadyExistsException. This is due to several reasons:
The current user is not allowed to see all elements of the folder and one of the not-visible elements has this name
Another user has created an element in the meantime that has the same id

Parameters:
displayname - the displayname supplied for the IResource/code>
targetfolder - the folder in which the new IResource with the given displayname is to be created
Returns:
IDProposal which contains the proposed id and gives further information why and how the proposed id differs from the given displayname
Throws:
WcmException

generateIDs

public List generateIDs(List displaynames,
                        ICollection targetfolder)
                 throws WcmException
generates ID proposals based on the list with displaynames that are valid within the given targetfolder. The returned classes contain the proposed id and will give further information why and how the proposed id differs from the given displayname. The objects of the returned list will be in the same order as the displaynames of the imported list were.

Parameters:
displaynames - a list that must contain only String objects
targetfolder - the folder in which the new IResource with the given displayname is to be created
Returns:
a list with IDProposal objects
Throws:
WcmException
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2014 SAP AG Complete Copyright Notice