WebPubResource
represents information common to all resources. You can copy or move a resource to a new location (URL) and you can manipulate its attributes.WebPubContainer
represents information about containers. You can create, delete, or index containers. Typically, a container corresponds to a filesystem directory.WebPubContainer
is a subclass of WebPubResource
.WebPubComponent
represents information about components. You can do a variety of things to a component, such as locking or editing the component. Typically, a component corresponds to a filesystem file. WebPubComponent
is a subclass of WebPubResource
.WPAttributeValue
, WPAuthentication
, WPIndexResource
, and WPVersionInfo
store particular information about a resource.
The WPStatus
interface stores return information from all methods of the WebPubResource
, WebPubContainer
, and WebPubComponent
objects.
To manipulate a physical resource, you create a resource object of the appropriate type, based on the URL of the physical resource you wish to manipulate. You may also need an authentication string to allow access to the resource. Once you have an appropriate object, you can use the methods of that resource object to perform actions on the associated physical resource. The object exists only as long as the application that created it. The physical resource exists independently of this object.
You can think of a resource object as a "handle" for the physical resource that exists on the remote server. This is analogous to the notion of a file handle in a file system.
You should remember this distinction between the physical resource and the resource object you use to manipulate that resource. The resource object is ephemeral; you create it to perform specific manipulations on the physical resource with which it is associated. The existence of the physical resource is separate from that of the object you use to manipulate it. For example, creating a container object does not automatically create the corresponding physical container. To create the physical container, you must call the container object's create
method.
Some of the actions you can perform on physical resources using resource objects are:
WebPubResource
WebPubContainer
WebPubComponent
WPAttributeValue
WPAuthentication
WPIndexResource
WPVersionInfo
WPStatus
$nshome
/plugins/content_mgr/client/WebPubProtocol.jar
where $nshome
is the directory in which you installed the server. You can use these classes as part of a Java application or Java applet. These classes work with JDK 1.02 (or later). The examples in "Programming Examples" are valid both for applets and applications.
NOTE:
If you are using an earlier version of Navigator (that is, earlier than Navigator 3.01), the
Web Publishing classes are on the server at $nshome/plugins/content_mgr/
client/WebPubArchive30.zip
. Note that this zip file does not contain all the Web
Publisher problem solutions that have been resolved since the initial product release. To
get all recent solutions, you must use the jar file.
WebPubProtocol.jar
(or WebPubArchive30.zip
) to a directory of your choosing on your client machine (that is, the machine that will run the Java application). Once you've put this file in an appropriate directory, change your CLASSPATH variable to include it. For example, if you copy the file to the c:\javastuff
directory, add the following to your CLASSPATH:
c:\javastuff\WebPubProtocol.jarOr (for older browsers only):
c:\javastuff\WebPubArchive30.zip
WebPubProtocol.jar
file must be in the compiler's CLASSPATH. To ensure this is true, either copy the WebPubProtocol.jar
file to a path that is already in the compiler's CLASSPATH, or add the following directory to the CLASSPATH:
$nshome
/plugins/content_mgr/client/WebPubProtocol.jar
When you put the compiled class in the root directory (or a a subdirectory thereof) on the Enterprise Server, there is no need to copy the WebPubProtocol.jar file over too.
To run a Java applet that uses Web Publishing classes, you must use Netscape Navigator 3.01 (or a later version). Earlier versions of the Navigator browser cannot access your local disk.
With Navigator 3.01, you need to install the Web Publisher plugin and the older WebPubArchive30.zip
file before the server can run applets that use the Web Publishing classes. With Navigator 4.0 (or later), you do not need to install this plugin.
To install the Web Publisher Plugin, go to the Enterprise Server 3.x home page for your installation. From that page, follow the link to the Web Publisher home page. On the Web Publisher home page, follow the instructions to download and install the Web Publisher Plugin on your client. (Before you can access the Web Publisher home page, you must have enabled Web Publishing through the Enterprise Administration interface.)
$nshome
/plugins/content_mgr/client/bin
copy
method is defined for WebPubResource
. If the only thing you want to do with the original resource is to copy it, you can create a WebPubResource
object to perform the copy. Alternatively, if you want to do something else to the original resource that is specific to the type of resource (such as editing or locking a component or indexing a container), you can create a WebPubComponent
or WebPubContainer
object instead and use its copy
method.
In this example, the client application creates a WebPubResource
object to copy the resource (in this case, a file) at:
http://aceindustry/draft/apidoc
to a new location at:
http://aceindustry/release/apidoc.htm
.
In this case, the user gilligan
with password 3HourTour
is known to the Enterprise Server either through an associated Directory Server or because he has already been added as a user to the server.
The example code has steps which are explained in a discussion following the code.
// java.net.URL provides the URL class
// netscape.net.* provides WPAuthentication and WebPubResource classes
import java.net.URL;
import netscape.net.*;
/* Step 1. Create an authentication object.*/
WPAuthentication auth = new WPAuthentication ("gilligan", "3HourTour");
/* Step 2. Get the URLs for the originating and destination locations.*/
URL origURL=null;
URL destURL=null;
try
{
origURL = new URL ("http://aceindustry/draft/apidoc");
destURL = new URL("http://aceindustry/release/apidoc");
}
catch(Exception e)
{
System.out.println("Exception while creating URL: "+e.toString());
return;
}
/* Step 3. Create a resource object. */
WebPubResource resource = new WebPubResource (origURL, auth);
/* Step 4 Copy the resource.*/
WPStatus status = resource.copy (destURL);
/* Step 5. Check the status of the copy operation. */
if (status.getStatusCode() == 200)
System.out.println("Copied " + origURL + " to " + destURL);
else
System.out.println("Copied failed because: " +
status.getStatusString());
"
gilligan"
and the password is "
3HourTour"
. This step creates a WPAuthentication
object used to establish authenticated access to the server on behalf of the client. WPAuthentication auth = new WPAuthentication ("gilligan", "3HourTour");
URL
objects corresponding to the original and new locations for the resource. You must create the URL
objects inside a try
block in case an exception is signalled when creating them.URL origURL=null;
URL destURL=null;
try
{
origURL = new URL ("http://aceindustry/draft/apidoc");
destURL = new URL("http://aceindustry/release/apidoc");
}
catch(Exception e)
{
System.out.println("Exception while creating URL: "
+ e.toString());
return;
}
WPAuthentication
object and the URL objects, create the WebPubResource
object. You need to use a URL object that points to the resource and an authentication object that indicates a valid user and password.WebPubResource resource = new WebPubResource (origURL, auth);
WebPubResource
object exists, this step copies it. WPStatus
is the return type for all methods of the WebPubResource
, WebPubContainer
, and WebPubComponent
objects. If the client needs to know the return status of the copy call, it can invoke the getStatusCode
or getStatusString
methods of the WPStatus
object.WPStatus status = resource.copy (destURL);
getStatusString
method of a WPStatus
object returns a string explaining the status, such as "OK"
if the operation was successful, or "Unauthorized"
if the operation failed because the client was not authorized to perform it.if (status.getStatusCode() == 200)
System.out.println("Copied " + origURL + " to " + destURL);
else
System.out.println("Copied failed because: " +
status.getStatusString());
http://aceindustry/release/apidoc.htm
.
The example code has steps which are explained in a discussion following the code.
// java.net.URL provides the URL class
// netscape.net.* provides WPAuthentication and WebPubResource classes
// java.io.File provides the File class
import java.net.URL;
import netscape.net.*;
import java.io.File;
/* Step 1. Create the authentication object. */
WPAuthentication auth = new WPAuthentication ("gilligan", "3HourTour");
/* Step 2. Create the version info object. */
WPVersionInfo versionInfo = new WPVersionInfo ("head", null,
WPVersionInfo.locked, null);
/* Step 3. Create the URL for the component. */
URL url;
try
{
url = new URL ("http://aceindustry/release/apidoc");
}
catch(Exception e)
{
System.out.println("Exception while creating URL: "+e.toString());
return;
}
/* Step 4. Create the WebPubComponent object. */
WebPubComponent component = new WebPubComponent (url, auth, versionInfo);
/* Step 5. */
File file = new File ("some Filename");
WPStatus status = component.edit (file);
/* Step 6. Edit the file. */
// Make changes to the content of the file.
// Code omitted here.
/* Step 7. Upload the changed content. */
component.save(file);
WPAuthentication auth = new WPAuthentication ("gilligan", "3HourTour");
WPVersionInfo
object. WPVersionInfo versionInfo = new WPVersionInfo ("head", null, WPVersionInfo.locked, null);
"head"
indicates the head of the version tree (that is, the most recent version).URL
object inside a try
block in case an error occurs creating the object.URL url;
try
{ url = new URL ("http://aceindustry/release/apidoc");
}
catch(Exception e)
{ System.out.println("Exception while creating URL: "
+ e.toString());
return;
}
WebPubComponent
object. The url
argument is the URL for the component. The auth
argument is an authentication object indicating a valid user and password. The versionInfo
argument is a version info object indicating which version of the component we are interested in. WebPubComponent component = new WebPubComponent (url, auth, versionInfo);
edit
method. This method downloads the component to a file or buffer, and locks it if appropriate. Here we download to a file. The file
parameter is an object of class File
which refers to the local file on the client in which to put a copy of the resource while editing it. The file must exist before the download occurs. Here we create a new file.File file = new File ("someFilename");
WPStatus status = component.edit (file);
// Make changes to the content of the file.
// Code omitted here.
save
method saves the content of the indicated file or buffer (in this case it is a file) back to the component on the server. When the component was created, it was given a version info object indicating which version it pertains to. The save
method saves the content back to that version. If the component was locked, it is unlocked after the save operation.component.save(file);
MyServer
and the path of the versioned file is help.htm
in the directory apps.
The user gilligan
with password 3HourTour
is known to the Enterprise Server.
The example code has steps which are explained in a discussion following the code.
import netscape.net.*;
import java.net.*;
import java.util.*;
/* Step 1. Create the authentication object */
String userID = new String ("gilligan");
String password = new String ("3HourTour");
WPAuthentication auth = new WPAuthentication (userID, password);
/* Step 2. Get the URL for the component */
URL url;
try
{
url = new URL ("http://MyServer/apps/help.htm");
}
catch(Exception e)
{
System.out.println("Exception while creating URL:
"+e.toString());
return;
}
/* Step 3. Create a WebPubComponent object for the component */
WebPubComponent component = new WebPubComponent (url, auth);
/* Step 4. Get the component's revision numbers. */
Vector vec = new Vector();
WPStatus status = component.revNum (vec);
/* Step 5. If the component has revision numbers, print them. */
if (status.getStatusCode() == 200)
{ Enumeration enum = vec.elements();
System.out.println("The component at " + url +
" has the following version numbers: ");
while (enum.hasMoreElements())
{ System.out.println ("Rev Number: " + enum.nextElement());
}
}
else
{ System.out.println("The component at " + url +
" is not under version control.");
}
String userID = new String ("gilligan");
String password = new String ("3HourTour");
WPAuthentication auth = new WPAuthentication (userID, password);
URL url;
try
{
url = new URL ("http://MyServer/apps/help.htm");
}
catch(Exception e)
{
System.out.println("Exception while creating URL:
"+e.toString());
return;
}
WebPubComponent
object that represents the component.WebPubComponent component = new WebPubComponent (url, auth);
revNum
method puts the version numbers in the vector and sets the status to 200 (OK). If the component is not under version control, there are no revision numbers and the status is set to some other value such as 404 (Not Found).Vector vec = new Vector();
WPStatus status = component.revNum (vec);
if (status.getStatusCode() == 200)
{ Enumeration enum = vec.elements();
System.out.println("The component at " + url +
" has the following version numbers: ");
while (enum.hasMoreElements())
{ System.out.println ("Rev Number: " + enum.nextElement());
}
}
else
{ System.out.println("The component at " + url +
" is not under version control.");
}
Last Updated: 03/10/99 13:42:01