| Oracle® Workspaces Web Services Application Developer's Guide 10g Release 1 (10.1.2.2) Part Number B28207-01 |
|
|
View PDF |
An attachment (which is called a link in the Oracle Workspace user interface) is a mechanism that associates resource items with each other. The following are some of the tasks that you may perform with the Attachments service:
Attach one Oracle Workspaces resource item with another. For example you may attach a discussion thread to a file.
Attach multiple resource items to a resource item.
Query the attachments attached to a particular resource item (target attachments).
Query the resource item to which an entity is attached (source attachments).
The following sample creates a board (or retrieves it if it already exists), creates a meeting, and creates an attachment that associates the board to the meeting:
Example 15-1 AttachmentsServiceSample.java
package oracle.sample.workspaces.ws;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import oracle.workspaces.ws.AttachmentsService;
import oracle.workspaces.ws.AttachmentsServiceServiceLocator;
import oracle.workspaces.ws.AttachmentsServiceSoapBindingStub;
import oracle.workspaces.ws.AuthenticationService;
import oracle.workspaces.ws.DiscussionService;
import oracle.workspaces.ws.HomeService;
import oracle.workspaces.ws.MeetingsService;
import oracle.workspaces.ws.beans.AttachmentDefinition;
import oracle.workspaces.ws.beans.BoardItem;
import oracle.workspaces.ws.beans.MeetingResourceItem;
import oracle.workspaces.ws.beans.WorkspaceItem;
import oracle.workspaces.ws.exceptions.CwWSException;
import org.apache.axis.transport.http.HTTPConstants;
public class AttachmentsServiceSample
{
public static AttachmentsService configureAttachmentsService(
String szAuthCookie) throws ServiceException
{
AttachmentsServiceServiceLocator assl =
new AttachmentsServiceServiceLocator();
AttachmentsService aService =
assl.getAttachmentsService();
((AttachmentsServiceSoapBindingStub)aService).
setMaintainSession(true);
((javax.xml.rpc.Stub) aService).
_setProperty(HTTPConstants.HEADER_COOKIE, szAuthCookie);
return aService;
}
public static void addAttachment(
AttachmentsService szAttachmentsService,
String szWorkspaceID,
String szItemBeingAttachedID,
String szItemReceivingAttachmentID)
throws RemoteException, CwWSException
{
// szItemBeingAttachedID is the UID of the entity
// being attached
//
// szItemReceivingAttachmentID is the UID of
// the entity to which the attachment is being added
AttachmentDefinition[] aDefArray = new AttachmentDefinition[1];
AttachmentDefinition aDef1 = new AttachmentDefinition();
aDef1.setDescription("Adding attachments as links");
aDef1.setEntityId(szItemBeingAttachedID);
aDefArray[0] = aDef1;
szAttachmentsService.addAttachments(
szWorkspaceID,
szItemReceivingAttachmentID,
aDefArray);
}
public static void main(String[] args)
{
try {
// Get authentication cookie
AuthenticationService myAuthenticationService =
AuthenticationSample.configureAuthenticationService(
"rg4",
"welcome1");
String authCookie = AuthenticationSample.getAuthenticationCookie
(myAuthenticationService);
System.out.println("Retrieved authentication cookie : " + authCookie);
// Get AttachmentsService and set authentication cookie
AttachmentsService myAttachmentsService =
AttachmentsServiceSample.configureAttachmentsService(authCookie);
// Get DiscussionSerivce and set authentication cookie
DiscussionService myDiscussionService =
DiscussionServiceSample.configureDiscussionService(authCookie);
// Get MeetingsService and set authentication cookie
MeetingsService myMeetingsService =
MeetingsServiceSample.configureMeetingsService(authCookie);
// Retrieve HomeService and set authentication cookie
HomeService myHomeService =
HomeServiceSample.configureHomeService(authCookie);
// Create new workspace (or retrieve it if it already exists)
WorkspaceItem myWorkspace =
HomeServiceSample.createOrRetrieveWorkspace(
myHomeService,
"NewWorkspace",
"My New Workspace",
"Description of My New Workspace",
"WRITER",
"ENABLED");
System.out.println("Retrieved or created workspace");
// Create a new meeting
MeetingResourceItem myMeeting =
MeetingsServiceSample.createMeetingForToday(
myMeetingsService,
myWorkspace.getWorkspaceUid());
System.out.println("Created new meeting");
// Create (or retrieve) a board
BoardItem myBoard =
DiscussionServiceSample.createDiscussionBoard(
myDiscussionService,
myWorkspace.getWorkspaceUid());
System.out.println("Created or retrieved board");
// The following method call will create a link from
// a board to a meeting
AttachmentsServiceSample.addAttachment(
myAttachmentsService,
myWorkspace.getWorkspaceUid(),
myMeeting.getId(),
myBoard.getId());
System.out.println("Created attachment");
myAuthenticationService.logout();
} catch (CwWSException cwwse)
{
System.out.println("CwWSException caught: " + cwwse.toString());
cwwse.printStackTrace();
} catch (Exception e)
{
System.out.println("Exception caught: " + e.toString());
}
}
}