edu.wisc.trace.uch.resource
Class ResourceManager

java.lang.Object
  extended by edu.wisc.trace.uch.resource.ResourceManager

public class ResourceManager
extends Object

Manage Resource Sheet, Local and Resource Server Resources. Also provide methods to upload/download resources as well as get their properties.

Version:
$Revision: 1.15 $
Author:
Parikshit Thakur & Team, Trace R&D Center

Constructor Summary
ResourceManager(UCH uch, String localResDirUri, String resServerAppPath, String cacheDirUri)
          Constructor.
ResourceManager(UCH uch, String localResDirUri, String resServerAppPath, String cacheDirUri, String userName, String password)
          Constructor.
 
Method Summary
 boolean addLocalResource(String ucfFileURI)
          Add resource derived by specifies UCF file to the local resources.
 void addResourceDir(String tdUri)
          Parse <ResDir> Element of Target Description and add it in the list of TargetDescriptions.
 List<String> clearCache()
          Clear all Atomic and Resource Server Resources.
 List<String> clearCache(String resourceType)
          Clear specified type of Resources.
 List<String> clearResourceSheetCache()
          Clear all the Resource Sheet resources.
 List<String> clearUipmClientCache()
          Clear all UIPM Client resources.
 String convertURI(String uri)
          Call the same method of UCH.
 List<Map<String,Object>> getDynRes(String sessionId, List<Map<String,String>> resProps)
          Called on UCH for getting Dynamic Resource.
 List<List<Map<String,List<String>>>> getResources(String sessionId, List<Map<String,List<String>>> resPropsList)
          Get Resources from Local Resources, Resource Server, Target Adapter or Resource Sheet as par the requested resource property resourceType.
 String getResServerAppPath()
          Get the String value of Resource Server app path.
 Map<String,List<String>> getResServerResource(Map<String,List<String>> resourceProps)
          Retrieve only best matched Resource from Resource Server.
 String getUserProfile()
          Get User Profile for logged user.
 boolean isUriContainsResServerAppPath(String uri)
          Call the same method of UCH.
 String retrieveResource(String uri)
          Retrieve the resource from Resource Server and save it in cache directory and return that file path.
 void updateDynRes(List<String> sessionIds, List<String> eltIds)
          Store Information about the Dynamic Resource.
 List<Map<String,String>> uploadResources(List<Map<String,List<String>>> props, List<String> owners, List<String> groups, Map<String,List<String>> rights, List<String> resourceUri)
          Upload Specified Resources with specified Properties, Owners and Groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceManager

public ResourceManager(UCH uch,
                       String localResDirUri,
                       String resServerAppPath,
                       String cacheDirUri)
Constructor. Assign reference of UCH to local variable.

Parameters:
uch - an Object of UCH
localResDirUri - a String value of local resource directory URI path.
resServerAppPath - a String value of Resource Server Path
cacheDirUri - a String value of Cache dir path

ResourceManager

public ResourceManager(UCH uch,
                       String localResDirUri,
                       String resServerAppPath,
                       String cacheDirUri,
                       String userName,
                       String password)
Constructor. Assign reference of UCH to local variable. Instantiate ResourceRetrival class using other parameters.

Parameters:
uch - an Object of UCH
localResDirUri - a String value of local resource directory URI path.
resServerAppPath - a String value of Resource Server Path
cacheDirUri - a String value of Cache dir path
userName - a String value of userName
password - a String value of password
Method Detail

getResServerAppPath

public String getResServerAppPath()
Get the String value of Resource Server app path.

Returns:
a String value

convertURI

public String convertURI(String uri)
Call the same method of UCH.

Parameters:
uri - a String value of URI
Returns:
a String value of converted URI

isUriContainsResServerAppPath

public boolean isUriContainsResServerAppPath(String uri)
Call the same method of UCH.

Parameters:
uri - a String value of URI
Returns:
return value from UCH

addResourceDir

public void addResourceDir(String tdUri)
Parse <ResDir> Element of Target Description and add it in the list of TargetDescriptions.

Parameters:
tdUri - a String value of Target Description URI(tdUri)

getDynRes

public List<Map<String,Object>> getDynRes(String sessionId,
                                          List<Map<String,String>> resProps)
Called on UCH for getting Dynamic Resource.

Parameters:
sessionId - a String value of Session Id
resProps - an Object of List<Map<String, String>>
Returns:
an Object of List<Map<String, Object>>

updateDynRes

public void updateDynRes(List<String> sessionIds,
                         List<String> eltIds)
Store Information about the Dynamic Resource. So when request for resource is made then first check it for Dynamic Resource. If not found then find Resource in available Resource Directories.

Parameters:
sessionIds - a List<String> value of sessionIds
eltIds - a List<String> value of elementIds

uploadResources

public List<Map<String,String>> uploadResources(List<Map<String,List<String>>> props,
                                                List<String> owners,
                                                List<String> groups,
                                                Map<String,List<String>> rights,
                                                List<String> resourceUri)
Upload Specified Resources with specified Properties, Owners and Groups.

Parameters:
props - an Object of List<Map<String, List<String>>> specifies Resource Properties
owners - an Object of List<String> specifies owners of Resource
groups - an Object of List<String> specifies groups of Resource
rights - an Object of Map<String, List<String>> specifies rights of Resource
resourceUri - a String value of local resource path URI
Returns:
an Object of List<Map<String, String>>

addLocalResource

public boolean addLocalResource(String ucfFileURI)
Add resource derived by specifies UCF file to the local resources.

Parameters:
ucfFileURI - a String value of UCF file.
Returns:
a boolean value specifies whether local resource added successfully or not

getUserProfile

public String getUserProfile()
Get User Profile for logged user.

Returns:
a string value specifies user profile file data.

getResources

public List<List<Map<String,List<String>>>> getResources(String sessionId,
                                                         List<Map<String,List<String>>> resPropsList)
Get Resources from Local Resources, Resource Server, Target Adapter or Resource Sheet as par the requested resource property resourceType. If request properties contains property 'http://myurc.org/ns/res#type' and its value is 'http://myurc.org/restypes#atomic' then go for atomic or dynamic resource. Else find resource from local resources and if not found then go to resource server to get it.

Parameters:
sessionId - a String value of SessionId
resPropsList - an Object of List<Map<String, List<String>>>
Returns:
a List<Map<String, Object>> of Resources.

retrieveResource

public String retrieveResource(String uri)
Retrieve the resource from Resource Server and save it in cache directory and return that file path.

Parameters:
uri - a String value of uri.
Returns:
a String value of file path.

getResServerResource

public Map<String,List<String>> getResServerResource(Map<String,List<String>> resourceProps)
Retrieve only best matched Resource from Resource Server.

Parameters:
resourceProps - an Object of Map<String, String>
Returns:
an Object of Map<String, Object>

clearCache

public List<String> clearCache()
Clear all Atomic and Resource Server Resources.

Returns:
an Object of List<String> specifies deleted file URIs

clearResourceSheetCache

public List<String> clearResourceSheetCache()
Clear all the Resource Sheet resources. Also clear downloaded Resource Sheets.

Returns:
an Object of List<String> specifies deleted file URIs

clearUipmClientCache

public List<String> clearUipmClientCache()
Clear all UIPM Client resources.

Returns:
an Object of List<String> specifies deleted file URIs

clearCache

public List<String> clearCache(String resourceType)
Clear specified type of Resources.

Parameters:
resourceType - a String value of Resource Type
Returns:
an Object of List<String> specifies deleted file URIs


Copyright © 2006-2008 Trace R&D Center, University of Wisconsin-Madison. All Rights Reserved.