com.ptc.windchill.uwgm.proesrv.rrc
Class RequestResultCache

java.lang.Object
  extended bycom.ptc.windchill.uwgm.proesrv.rrc.RequestResultCache

public final class RequestResultCache
extends Object

A cache to compose the data for the response.


Nested Class Summary
private static class RequestResultCache.LocalIdInfo
          Information attached to WorkspaceUpdateMessage_i in order to fill up its DbObjects collection with onew objects created during an upload.
static interface RequestResultCache.Populator
           
private static class RequestResultCache.RequestedAttributes
           
 
Field Summary
private  RequestContext context
           
private  EPMWorkspace currentEpmWS
           
private static com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType[] EMPTY_LAZY_ATTRS
           
private  Map epmIterAttrs
           
private  RequestResultCache.RequestedAttributes epmIterRA
           
(package private)  RRCFakeFolderHelper fakeFolderHelper
           
(package private)  DbObjCache folderCache
           
(package private)  DbObjCache globalCache
           
(package private)  Map localIdInfoMap
           
(package private)  Map localIdMap
           
private static Log log
           
private  List messages
           
private static RequestResultCache.RequestedAttributes NO_REQUESTED_ATTRS
           
(package private)  UwgmObjectFactory objFactory
           
(package private)  ObjectIdentifierHelper oidHelper
           
(package private)  WsOriginalStateHelper origStateHelper
           
private  Map partIterAttrs
           
private  RequestResultCache.RequestedAttributes partIterRA
           
(package private)  String[] prefferedContentUrls
           
private  Map requestIdMap
           
private  List requests
           
(package private) static String RESOURCE
          RRC package resource bundle
(package private)  com.ptc.windchill.uwgm.soap.uwgmdb.Workspace[] workspaces
           
(package private)  Map wsClinetStateMap
           
 
Constructor Summary
RequestResultCache(RequestContext context)
           
 
Method Summary
(package private)  void addInfoElement(InfoElement message)
           
(package private)  void addNewlyCreatedObject(com.ptc.windchill.uwgm.soap.uwgmdb.DbObj dbObj)
           
 RequestResultCache.Populator addRequest(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest request)
           
(package private)  boolean attributeRequested(com.ptc.windchill.uwgm.soap.uwgmdb.EpmIteration obj, com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
          Package-private method to effectively check if an attribute of a given type has been requested for a particular EpmIteration
private  boolean attributeRequested(Map attrMap, com.ptc.windchill.uwgm.soap.uwgmdb.DbObj obj, com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
           
(package private)  boolean attributeRequested(com.ptc.windchill.uwgm.soap.uwgmdb.PartIteration obj, com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
          Package-private method to effectively check if an attribute of a given type has been requested for a particular PartIteration
private  void buildEpmIterationAttrsMaps()
           
private  void buildPartIterationAttrsMaps()
           
(package private)  com.ptc.windchill.uwgm.soap.impl.uwgmdb.Content_i createContent(ContentItem item)
           
 RequestContext getContext()
           
 EPMWorkspace getCurrentEpmWS()
          Will return the last set WS.
private  Collection getFolderEpmIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Folder folder)
           
private  Collection getFolderIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Folder folder, Class iterClass)
           
 InfoElement[] getInfoElements()
          All info and warning mesages collected during post-processing.
 Locale getLocale()
           
(package private)  String getNDVersion(EPMDocument epmDoc)
           
 String getOidString(ObjectIdentifier oid)
           
 String getOidString(Persistable obj)
           
 String getOidString(WTReference ref)
           
 WTPrincipal getPrincipal()
           
 RequestResultCache.Populator getRequestCache(String requestId)
           
(package private)  com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes getRequestedAttributes(com.ptc.windchill.uwgm.soap.uwgmdb.EpmIteration obj)
          Package-private method to effectively check if an attribute of a given type has been requested for a particular EpmIteration
(package private)  com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes getRequestedAttributes(com.ptc.windchill.uwgm.soap.uwgmdb.PartIteration obj)
          Package-private method to effectively check if an attribute of a given type has been requested for a particular PartIteration
private  Collection getWorkspaceEpmIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Workspace ws)
           
private  Collection getWorkspaceIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Workspace ws, Class iterClass)
           
(package private)  String getWorkspacePageURL(EPMWorkspace epmWS)
           
 void ignoreOriginalState(Workable iter)
           
 void ignoreWorkspaceOriginalState(EPMWorkspace epmWS)
          Marks the WS to always retrieve all requested attributes regardless of the original state.
private  boolean isNullOrHasAttribute(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes ra, com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
           
 boolean isRequestFailed(String requestId)
           
 void postProcess()
           
private  void processAssociated()
           
private  void processContainers()
           
private  void processContentInfo()
           
private  void processEpmIterations()
           
private  void processEpmMasters()
           
private  void processFamilyTables()
           
private  void processFoldered()
          For all Foldered objects which are already in the cache, check if LocationFolder attribute is requested and make sure the corresponding Folder object is also there.
private  void processFolders()
           
private  void processIbaHolders()
           
private  void processNewlyCreatedObjects()
           
private  void processPartIterations()
           
private  void processPartMasters()
           
private  void processPdmState()
           
private  void processProductViewInfo()
           
private  void processUpdateCounters()
           
private  void processWorkspaceFamilyTables()
          Fill in the WorkspaceFamilyTables lazy attribute for workspaces with ignored original state.
private  void processWorkspaces()
           
(package private)  void reportException(String resourceCode, Throwable t, Persistable applicableObject)
          Convenience method.
(package private)  void reportException(String resourceCode, Throwable t, WTCollection applicableObjects)
          Create warning InfoElement with applicable objects.
(package private)  void reportFailure(String resourceCode, Persistable applicableObject)
          Convenience method.
(package private)  void reportFailure(String resourceCode, WTCollection applicableObjects)
          Create warning InfoElement with applicable objects.
 void resetCurrentEpmWS()
           
 void setCurrentEpmWS(EPMWorkspace epmWS)
           
(package private)  void setDbObjAttrs(com.ptc.windchill.uwgm.soap.uwgmdb.DbObj entity, Persistable wtObj, com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes ra)
          Set the simplest attributes from the Persistable.
 void setLocalIdMap(com.ptc.windchill.uwgm.soap.impl.uwgmsvc.WorkspaceUpdateMessage_i wsMessage, Map idMap)
          Append String pairs [OID]->[Local ID] to the Map being used to resolve LocalIDs for upload request results.
 void setPrefferedContentUrls(String[] urls)
           
 void setWorkspaceOriginalState(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest request, EPMWorkspace epmWS)
          For a request which returns WorkspaceMessage, retrieve and remember the original state of the WS in order to optimize post-processing.
(package private)  void throwUwgmErrorException(String resourceCode, Throwable t, Persistable applicableObject)
          Convenience method to construct and throw UwgmErrorException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

static final String RESOURCE
RRC package resource bundle


log

private static final Log log

oidHelper

final ObjectIdentifierHelper oidHelper

context

private final RequestContext context

currentEpmWS

private EPMWorkspace currentEpmWS

prefferedContentUrls

String[] prefferedContentUrls

requests

private final List requests

requestIdMap

private final Map requestIdMap

epmIterAttrs

private final Map epmIterAttrs

partIterAttrs

private final Map partIterAttrs

epmIterRA

private final RequestResultCache.RequestedAttributes epmIterRA

partIterRA

private final RequestResultCache.RequestedAttributes partIterRA

workspaces

com.ptc.windchill.uwgm.soap.uwgmdb.Workspace[] workspaces

origStateHelper

final WsOriginalStateHelper origStateHelper

wsClinetStateMap

final Map wsClinetStateMap

folderCache

DbObjCache folderCache

fakeFolderHelper

final RRCFakeFolderHelper fakeFolderHelper

localIdMap

final Map localIdMap

localIdInfoMap

final Map localIdInfoMap

globalCache

final DbObjCache globalCache

objFactory

final UwgmObjectFactory objFactory

messages

private final List messages

EMPTY_LAZY_ATTRS

private static final com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType[] EMPTY_LAZY_ATTRS

NO_REQUESTED_ATTRS

private static final RequestResultCache.RequestedAttributes NO_REQUESTED_ATTRS
Constructor Detail

RequestResultCache

public RequestResultCache(RequestContext context)
Method Detail

addRequest

public RequestResultCache.Populator addRequest(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest request)

getRequestCache

public RequestResultCache.Populator getRequestCache(String requestId)

isRequestFailed

public boolean isRequestFailed(String requestId)

getContext

public RequestContext getContext()

getLocale

public Locale getLocale()

getPrincipal

public WTPrincipal getPrincipal()

getCurrentEpmWS

public EPMWorkspace getCurrentEpmWS()
Will return the last set WS.

Returns:
EPMWorkspace

setCurrentEpmWS

public void setCurrentEpmWS(EPMWorkspace epmWS)

resetCurrentEpmWS

public void resetCurrentEpmWS()

setWorkspaceOriginalState

public void setWorkspaceOriginalState(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest request,
                                      EPMWorkspace epmWS)
For a request which returns WorkspaceMessage, retrieve and remember the original state of the WS in order to optimize post-processing. For all iterations which have remained unchanged by the end of the transaction most of requested attributes will be ignored, except for the DbObjId and update counter (StateId).

Parameters:
request - UwgmRequest
epmWS - EPMWorkspace

ignoreWorkspaceOriginalState

public void ignoreWorkspaceOriginalState(EPMWorkspace epmWS)
Marks the WS to always retrieve all requested attributes regardless of the original state. Prevents the optimization prescribed by the setWorkspaceOriginalState() call.

Parameters:
epmWS - EPMWorkspace

ignoreOriginalState

public void ignoreOriginalState(Workable iter)

setPrefferedContentUrls

public void setPrefferedContentUrls(String[] urls)

setLocalIdMap

public void setLocalIdMap(com.ptc.windchill.uwgm.soap.impl.uwgmsvc.WorkspaceUpdateMessage_i wsMessage,
                          Map idMap)
Append String pairs [OID]->[Local ID] to the Map being used to resolve LocalIDs for upload request results.

Parameters:
wsMessage - WorkspaceUpdateMessage_i to add new objects
idMap - Map [OID String]->[Local ID String]

getInfoElements

public InfoElement[] getInfoElements()
All info and warning mesages collected during post-processing.

Returns:
InfoElement[], may be zero-size but never null

getOidString

public String getOidString(Persistable obj)

getOidString

public String getOidString(ObjectIdentifier oid)

getOidString

public String getOidString(WTReference ref)

postProcess

public void postProcess()
                 throws UwgmErrorException
Throws:
UwgmErrorException

buildEpmIterationAttrsMaps

private void buildEpmIterationAttrsMaps()
                                 throws UwgmErrorException
Throws:
UwgmErrorException

buildPartIterationAttrsMaps

private void buildPartIterationAttrsMaps()
                                  throws UwgmErrorException
Throws:
UwgmErrorException

addInfoElement

void addInfoElement(InfoElement message)

reportException

void reportException(String resourceCode,
                     Throwable t,
                     WTCollection applicableObjects)
Create warning InfoElement with applicable objects.

Parameters:
resourceCode - constant from rrcResources.rbInfo
t - Throwable
applicableObjects - WTCollection

reportFailure

void reportFailure(String resourceCode,
                   WTCollection applicableObjects)
Create warning InfoElement with applicable objects.

Parameters:
resourceCode - constant from rrcResources.rbInfo
applicableObjects - WTCollection

reportException

void reportException(String resourceCode,
                     Throwable t,
                     Persistable applicableObject)
Convenience method. Create warning InfoElement with exactly one applicable object.

Parameters:
resourceCode - constant from rrcResources.rbInfo
t - Throwable
applicableObject - Persistable

reportFailure

void reportFailure(String resourceCode,
                   Persistable applicableObject)
Convenience method. Create warning InfoElement with exactly one applicable object.

Parameters:
resourceCode - constant from rrcResources.rbInfo
applicableObject - Persistable

throwUwgmErrorException

void throwUwgmErrorException(String resourceCode,
                             Throwable t,
                             Persistable applicableObject)
                       throws UwgmErrorException
Convenience method to construct and throw UwgmErrorException. Creates ErrorElement with exactly one applicable object.

Parameters:
resourceCode - constant from rrcResources.rbInfo
t - Throwable
applicableObject - Persistable
Throws:
UwgmErrorException - - always!!!

attributeRequested

boolean attributeRequested(com.ptc.windchill.uwgm.soap.uwgmdb.EpmIteration obj,
                           com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
Package-private method to effectively check if an attribute of a given type has been requested for a particular EpmIteration

Parameters:
obj - EpmIteration
attrType - UwgmLazyAttrType
Returns:
boolean

getRequestedAttributes

com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes getRequestedAttributes(com.ptc.windchill.uwgm.soap.uwgmdb.EpmIteration obj)
Package-private method to effectively check if an attribute of a given type has been requested for a particular EpmIteration

Parameters:
obj - EpmIteration
Returns:
UwgmRequest.RequestedAttributes

attributeRequested

boolean attributeRequested(com.ptc.windchill.uwgm.soap.uwgmdb.PartIteration obj,
                           com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)
Package-private method to effectively check if an attribute of a given type has been requested for a particular PartIteration

Parameters:
obj - PartIteration
attrType - UwgmLazyAttrType
Returns:
boolean

getRequestedAttributes

com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes getRequestedAttributes(com.ptc.windchill.uwgm.soap.uwgmdb.PartIteration obj)
Package-private method to effectively check if an attribute of a given type has been requested for a particular PartIteration

Parameters:
obj - PartIteration
Returns:
UwgmRequest.RequestedAttributes

attributeRequested

private boolean attributeRequested(Map attrMap,
                                   com.ptc.windchill.uwgm.soap.uwgmdb.DbObj obj,
                                   com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)

getNDVersion

String getNDVersion(EPMDocument epmDoc)

getWorkspaceEpmIterations

private Collection getWorkspaceEpmIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Workspace ws)

getWorkspaceIterations

private Collection getWorkspaceIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Workspace ws,
                                          Class iterClass)

getFolderEpmIterations

private Collection getFolderEpmIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Folder folder)

getFolderIterations

private Collection getFolderIterations(com.ptc.windchill.uwgm.soap.uwgmdb.Folder folder,
                                       Class iterClass)

processPdmState

private void processPdmState()

processUpdateCounters

private void processUpdateCounters()

processAssociated

private void processAssociated()

processFamilyTables

private void processFamilyTables()
                          throws UwgmErrorException
Throws:
UwgmErrorException

processContentInfo

private void processContentInfo()
                         throws UwgmErrorException
Throws:
UwgmErrorException

processFoldered

private void processFoldered()
                      throws UwgmErrorException
For all Foldered objects which are already in the cache, check if LocationFolder attribute is requested and make sure the corresponding Folder object is also there.

Throws:
UwgmErrorException

processWorkspaces

private void processWorkspaces()
                        throws UwgmErrorException
Throws:
UwgmErrorException

processWorkspaceFamilyTables

private void processWorkspaceFamilyTables()
Fill in the WorkspaceFamilyTables lazy attribute for workspaces with ignored original state.

Throws:
UwgmErrorException

processFolders

private void processFolders()
                     throws UwgmErrorException
Throws:
UwgmErrorException

processContainers

private void processContainers()
                        throws UwgmErrorException
Throws:
UwgmErrorException

processEpmIterations

private void processEpmIterations()
                           throws UwgmErrorException
Throws:
UwgmErrorException

processEpmMasters

private void processEpmMasters()
                        throws UwgmErrorException
Throws:
UwgmErrorException

processPartIterations

private void processPartIterations()
                            throws UwgmErrorException
Throws:
UwgmErrorException

processPartMasters

private void processPartMasters()
                         throws UwgmErrorException
Throws:
UwgmErrorException

processIbaHolders

private void processIbaHolders()
                        throws UwgmErrorException
Throws:
UwgmErrorException

processProductViewInfo

private void processProductViewInfo()

isNullOrHasAttribute

private boolean isNullOrHasAttribute(com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes ra,
                                     com.ptc.windchill.uwgm.soap.uwgm.UwgmLazyAttrType attrType)

setDbObjAttrs

void setDbObjAttrs(com.ptc.windchill.uwgm.soap.uwgmdb.DbObj entity,
                   Persistable wtObj,
                   com.ptc.windchill.uwgm.soap.uwgm.UwgmRequest.RequestedAttributes ra)
Set the simplest attributes from the Persistable.

Parameters:
entity - DbEntity
wtObj - Persistable
ra - RequestedAttributes, may be null to set all

createContent

com.ptc.windchill.uwgm.soap.impl.uwgmdb.Content_i createContent(ContentItem item)

getWorkspacePageURL

String getWorkspacePageURL(EPMWorkspace epmWS)

addNewlyCreatedObject

void addNewlyCreatedObject(com.ptc.windchill.uwgm.soap.uwgmdb.DbObj dbObj)

processNewlyCreatedObjects

private void processNewlyCreatedObjects()