Oracle® Workspaces Web Services Application Developer's Guide 10g Release 1 (10.1.2.2) Part Number B28207-01 |
|
|
View PDF |
The Library service allows you to create folders, list quotas, and manage categories, workflow, trash folders, and versioning. The Library service does not allow you to create or upload files.
The following sample creates two folders in the library component of a specified workspace, then outputs information about the contents of the library component:
Example 8-1 LibraryServiceSample.java
package oracle.sample.workspaces.ws; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import oracle.workspaces.ws.AuthenticationService; import oracle.workspaces.ws.HomeService; import oracle.workspaces.ws.LibraryService; import oracle.workspaces.ws.LibraryServiceServiceLocator; import oracle.workspaces.ws.LibraryServiceSoapBindingStub; import oracle.workspaces.ws.beans.FilesResourceItem; import oracle.workspaces.ws.beans.WorkspaceItem; import oracle.workspaces.ws.exceptions.CwWSException; import org.apache.axis.transport.http.HTTPConstants; public class LibraryServiceSample { public static LibraryService configureLibraryService( String szAuthCookie) throws ServiceException { // Invoke an instance of library service locator and // get a handle to library service. LibraryServiceServiceLocator lssl = new LibraryServiceServiceLocator(); LibraryService libService = lssl.getLibraryService(); ((LibraryServiceSoapBindingStub)libService). setMaintainSession(true); ((javax.xml.rpc.Stub)libService). _setProperty(HTTPConstants.HEADER_COOKIE, szAuthCookie); return libService; } public static FilesResourceItem createFolderInWorkspace( LibraryService szLibraryService, String szWorkspaceID, String szFolderName, String szFolderDesc) throws RemoteException { try { return szLibraryService.createFolder( szWorkspaceID, null, // This folder does not have a parent folder szFolderName, szFolderDesc ); } catch (CwWSException e) { System.out.println("CwWSException caught while " + "creating folder: " + e.getMessage()); } return null; } public static FilesResourceItem[] getContentsOfWorkspace( LibraryService szLibraryService, String szWorkspaceID, String szSearchString) throws RemoteException, CwWSException { // Retrieve the contents of the library component // of a specified workspace, // then output information about each item found FilesResourceItem[] libraryContents = szLibraryService.listContents( szWorkspaceID, null, szSearchString); if (libraryContents == null) { System.out.println("Library contents are null"); } else { for (int i = 0; i < libraryContents.length; i++ ) { System.out.println("Item #" + i + ": " + libraryContents[i].getName() + ", " + libraryContents[i].getDescription() + ", " + libraryContents[i].getId() + ", " + libraryContents[i].getResourceItemType()); } } return libraryContents; } public static void main(String[] args) { try { // Get authentication cookie AuthenticationService myAuthenticationService = AuthenticationSample.configureAuthenticationService( "orcladmin", "welcome1"); String authCookie = AuthenticationSample.getAuthenticationCookie (myAuthenticationService); System.out.println("Retrieved authentication cookie : " + authCookie); // Get LibraryService and set authentication cookie LibraryService myLibraryService = LibraryServiceSample.configureLibraryService(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 some folders in the library resource LibraryServiceSample.createFolderInWorkspace( myLibraryService, myWorkspace.getWorkspaceUid(), "New Folder 1", "Description of New Folder 1"); System.out.println("Created 'New Folder 1'"); LibraryServiceSample.createFolderInWorkspace( myLibraryService, myWorkspace.getWorkspaceUid(), "New Folder 2", "Description of New Folder 2"); System.out.println("Created 'New Folder 2'"); // Output contents of library resource System.out.println("Contents of library component " + "of workspace:"); LibraryServiceSample.getContentsOfWorkspace( myLibraryService, myWorkspace.getWorkspaceUid(), "*"); myAuthenticationService.logout(); } catch (CwWSException cwwse) { System.out.println("CwWSException caught: " + cwwse.getMessage()); } catch (Exception e) { System.out.println("Exception caught: " + e.toString()); } } }