com.ibm.ram.repository.web
Class DownloadUtilities

java.lang.Object
  extended by com.ibm.ram.repository.web.DownloadUtilities

public class DownloadUtilities
extends java.lang.Object


Field Summary
static java.lang.String ECLIPSE_P2SITE_ARTIFACTS_JAR
           
static java.lang.String ECLIPSE_P2SITE_CONTENT_JAR
           
static java.lang.String ECLIPSE_UPDATESITE_FEATURES
           
static java.lang.String ECLIPSE_UPDATESITE_PLUGINS
           
static java.lang.String ECLIPSE_UPDATESITE_XML
           
 
Constructor Summary
DownloadUtilities()
           
 
Method Summary
static java.lang.String convertPathToWebServicesWAR(java.lang.String path)
          Converts a Web-WAR path (relative to the server) to a WebServices-WAR path.
static com.ibm.ram.internal.rest.RestContext createRequestContext(javax.servlet.http.HttpServletRequest request)
          Create a new RestContext based on the incoming request.
static com.ibm.ram.internal.rest.RequestStatus createRequestStatus(javax.servlet.http.HttpServletRequest request)
          Create a RequestStatus from the incoming request.
static java.lang.String downloadFile(javax.faces.context.FacesContext facesContext, com.ibm.ram.common.util.InputStreamInformation isInfo, java.lang.String fileName, java.lang.String description)
           
static java.lang.String getArtifactURL(java.lang.String guid, java.lang.String version, java.lang.String path, java.lang.String name, boolean isSubmissionAsset, boolean isPersisted)
          Same as getArtifactURL(String, String, String, String, boolean, boolean, boolean) with preview link set to false.
static java.lang.String getArtifactURL(java.lang.String guid, java.lang.String version, java.lang.String path, java.lang.String name, boolean isPersisted, boolean isPreview, boolean isSubmissionAsset)
          Constructs a URL for the artifact with path and name in the asset with guid and version.
static java.lang.String getAssetURL(java.lang.String guid, java.lang.String version, boolean submission)
          Get the URL for an asset
static java.lang.String getRequestBase(javax.servlet.http.HttpServletRequest request)
          Compute a Request base from servlet request.
static java.net.URI getStorageAccessURI(java.lang.String uriFromClient)
           
static java.lang.String makeArtifactUrlsRelative(java.lang.String contents)
          Make the Artifact URLs relative.
static java.lang.String makeRelativeArtifactUrlsAbsolute(java.lang.String contents, java.lang.String guid, java.lang.String version)
          Make the relative URLs (src="artifacts/folder1/folder2/filename") to absolute for an asset being displayed (src="http://serverpath/artifact/url-encoded-guid/url-encoded-version/folder1/folder2/filename").
static java.lang.String makeRelativeArtifactUrlsUpdateAbsolute(java.lang.String contents, java.lang.String submissionId)
          Make the relative urls (src="artifacts/folder1/folder2/filename") to absolute for an asset being updated (src="http://serverpath/artifact/upload/folder1/folder2/filename").
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ECLIPSE_UPDATESITE_XML

public static final java.lang.String ECLIPSE_UPDATESITE_XML
See Also:
Constant Field Values

ECLIPSE_P2SITE_ARTIFACTS_JAR

public static final java.lang.String ECLIPSE_P2SITE_ARTIFACTS_JAR
See Also:
Constant Field Values

ECLIPSE_P2SITE_CONTENT_JAR

public static final java.lang.String ECLIPSE_P2SITE_CONTENT_JAR
See Also:
Constant Field Values

ECLIPSE_UPDATESITE_FEATURES

public static final java.lang.String ECLIPSE_UPDATESITE_FEATURES
See Also:
Constant Field Values

ECLIPSE_UPDATESITE_PLUGINS

public static final java.lang.String ECLIPSE_UPDATESITE_PLUGINS
See Also:
Constant Field Values
Constructor Detail

DownloadUtilities

public DownloadUtilities()
Method Detail

getArtifactURL

public static java.lang.String getArtifactURL(java.lang.String guid,
                                              java.lang.String version,
                                              java.lang.String path,
                                              java.lang.String name,
                                              boolean isPersisted,
                                              boolean isPreview,
                                              boolean isSubmissionAsset)
Constructs a URL for the artifact with path and name in the asset with guid and version. If the asset has been submitted and is not being modified, isPersisted should be true.

Parameters:
guid - the GUID for the asset containing the artifact. If persist is true then this is GUID, if false then this is submission ID.
version - the version for the asset containing the artifact. If persist is true then this is version, if false then this is ignored.
path - the path within the asset to the artifact
name - the artifact name
isPersisted - Use true if this asset has already been submitted (i.e. the link is from the published asset content page). In this case guid is the actual guid, and version is the actual version. Use false if this asset is in the submission phase (i.e. the link is for asset in the content page of submit asset). In this case use SubmitAssetHandler.getSubmitId() for guid and version will be ignored.
isPreview - true if this should constructed as a preview link, or false if constructed as a regular link.
isSubmissionAsset - true if requesting artifact for a submission asset instead of the normal asset.
Returns:
the external URL for the artifact
Since:
7.0.0.1

getAssetURL

public static java.lang.String getAssetURL(java.lang.String guid,
                                           java.lang.String version,
                                           boolean submission)
Get the URL for an asset

Parameters:
guid -
version -
submission -
Returns:
Since:
7.1.1.1

getArtifactURL

public static java.lang.String getArtifactURL(java.lang.String guid,
                                              java.lang.String version,
                                              java.lang.String path,
                                              java.lang.String name,
                                              boolean isSubmissionAsset,
                                              boolean isPersisted)
Same as getArtifactURL(String, String, String, String, boolean, boolean, boolean) with preview link set to false.

Parameters:
guid -
version -
path -
name -
isSubmissionAsset - TODO
isPersisted -
Returns:
Since:
7.1

getStorageAccessURI

public static java.net.URI getStorageAccessURI(java.lang.String uriFromClient)

downloadFile

public static java.lang.String downloadFile(javax.faces.context.FacesContext facesContext,
                                            com.ibm.ram.common.util.InputStreamInformation isInfo,
                                            java.lang.String fileName,
                                            java.lang.String description)
                                     throws java.io.IOException
Throws:
java.io.IOException

makeArtifactUrlsRelative

public static java.lang.String makeArtifactUrlsRelative(java.lang.String contents)
Make the Artifact URLs relative. This takes "http://contextpath/artifact/upload/urlencoded-encoded-submitId/folder/file" and makes it "artifacts/folder/file". It is assumed that this is an update description (where the relative had been made absolute through makeRelativeArtifactUrlsUpdateAbsolute(String, String).

Note: This will use the current context path of the current faces request that the thread executing this method is under. This necessary because the links must be of the same context path so that they will be of the same session when they are clicked. If the server path was used and the server path is different than the context path then a new session would be needed for the link to executed.

Parameters:
contents -
Returns:
Since:
7.1

makeRelativeArtifactUrlsAbsolute

public static java.lang.String makeRelativeArtifactUrlsAbsolute(java.lang.String contents,
                                                                java.lang.String guid,
                                                                java.lang.String version)
Make the relative URLs (src="artifacts/folder1/folder2/filename") to absolute for an asset being displayed (src="http://serverpath/artifact/url-encoded-guid/url-encoded-version/folder1/folder2/filename"). This is used for display (not an asset being updated).

Note: This will use the current context path of the current faces request that the thread executing this method is under. This necessary because the links must be of the same context path so that they will be of the same session when they are clicked. If the server path was used and the server path is different than the context path then a new session would be needed for the link to executed.

Parameters:
contents - the contents to convert.
guid - the guid (it is assumed to not by URL encoded). It will become encoded in the absolute URL.
version - the version (it is assumed to not by URL encoded). It will become encoded in the absolute URL.
Returns:
Since:
7.1

makeRelativeArtifactUrlsUpdateAbsolute

public static java.lang.String makeRelativeArtifactUrlsUpdateAbsolute(java.lang.String contents,
                                                                      java.lang.String submissionId)
Make the relative urls (src="artifacts/folder1/folder2/filename") to absolute for an asset being updated (src="http://serverpath/artifact/upload/folder1/folder2/filename").

Note: This will use the current context path of the current faces request that the thread executing this method is under. This necessary because the links must be of the same context path so that they will be of the same session when they are clicked. If the server path was used and the server path is different than the context path then a new session would be needed for the link to executed.

Parameters:
contents -
submissionId - the submitId from the SubmitAssetHandler.
Returns:
Since:
7.1

convertPathToWebServicesWAR

public static java.lang.String convertPathToWebServicesWAR(java.lang.String path)
Converts a Web-WAR path (relative to the server) to a WebServices-WAR path. For invalid cases the original String is returned.

Valid cases:

Invalid cases:

Parameters:
path -
Returns:
Since:
7.2.0.2

createRequestContext

public static com.ibm.ram.internal.rest.RestContext createRequestContext(javax.servlet.http.HttpServletRequest request)
                                                                  throws java.net.URISyntaxException
Create a new RestContext based on the incoming request.

Parameters:
request - the incoming request
Returns:
the new rest context.
Throws:
java.net.URISyntaxException
Since:
7.5

createRequestStatus

public static com.ibm.ram.internal.rest.RequestStatus createRequestStatus(javax.servlet.http.HttpServletRequest request)
Create a RequestStatus from the incoming request.

Parameters:
request - the incoming request.
Returns:
the new request status.
Since:
7.5

getRequestBase

public static java.lang.String getRequestBase(javax.servlet.http.HttpServletRequest request)
Compute a Request base from servlet request. Used for RestContext.

Parameters:
request -
Returns:
the base.
Since:
7.5