public com.actuate.schemas.UploadFileResponse uploadFile( com.actuate.schemas.UploadFile request, org.apache.axis.attachments.AttachmentPart attachmentPart) throws RemoteException, RemoteException, ServiceException { com.actuate.schemas.UploadFileResponse response; try { proxy.addAttachment(attachmentPart); response = proxy.uploadFile(request); } finally { proxy.clearAttachments(); } return response; }
/** * Select a single page and save the result in the specified directory * * @param FileName * @param format * @param pageNumber * @param downloadDirectory * @return String the first file attachment name * @throws RemoteException */ public String selectJavaReportPage( String FileName, String format, int pageNumber, String downloadDirectory) throws RemoteException { // Set file name to view com.actuate.schemas.ObjectIdentifier objectIdentifier = new com.actuate.schemas.ObjectIdentifier(); objectIdentifier.setName(FileName); // Set the pages to view com.actuate.schemas.PageIdentifier pageIdentifier = new com.actuate.schemas.PageIdentifier(); pageIdentifier.setPageNum(new Long(pageNumber)); // Set the select page request com.actuate.schemas.SelectJavaReportPage selectJavaReportPage = new com.actuate.schemas.SelectJavaReportPage(); selectJavaReportPage.setObject(objectIdentifier); // selectJavaReportPage.setViewParameter(viewParameter); selectJavaReportPage.setPage(pageIdentifier); selectJavaReportPage.setDownloadEmbedded(new Boolean(true)); // SelectPage com.actuate.schemas.SelectJavaReportPageResponse selectJavaReportPageResponse = proxy.selectJavaReportPage(selectJavaReportPage); // Save the result in download directory new File(downloadDirectory).mkdir(); String firstAttachmentName = saveAttachment(selectJavaReportPageResponse.getPageRef(), downloadDirectory); return firstAttachmentName; }
public String saveNonEmbededResponse( String downloadDirectory, String localFileName, boolean decomposed) throws IOException, SOAPException, RemoteException { String downloadName = null; BufferedOutputStream outStream = null; String localFilePath = downloadDirectory + "/" + localFileName; try { if (!decomposed) { outStream = new BufferedOutputStream(new FileOutputStream(localFilePath)); } Object[] attachments = proxy.getAttachments(); for (int i = 0; i < attachments.length; i++) { if (attachments[i] != null) { AttachmentPart temp = (AttachmentPart) attachments[i]; System.out.println("Attachment retrived as " + temp.getContentId()); InputStream inStream = temp.getDataHandler().getInputStream(); if (!decomposed) { if (outStream != null) { saveToStream(inStream, outStream); } } else { String decomposedDocAttachment = downloadDirectory + "/" + temp.getContentId(); BufferedOutputStream tempOutStream = new BufferedOutputStream(new FileOutputStream(decomposedDocAttachment)); saveToStream(inStream, tempOutStream); tempOutStream.close(); } } } } catch (SOAPException e) { throw AxisFault.makeFault(e); } catch (RemoteException e) { throw e; } finally { proxy.clearAttachments(); if (outStream != null) { downloadName = localFilePath; outStream.close(); } } return downloadName; }
/** * Convenient function to run an array of administrate operation and handle the RemoteException * * @param adminOperation * @return boolean TRUE if there is no error */ public boolean runAdminOperation(com.actuate.schemas.AdminOperation[] adminOperations) { com.actuate.schemas.Administrate administrate = new com.actuate.schemas.Administrate(); administrate.setAdminOperation(adminOperations); try { com.actuate.schemas.AdministrateResponse administrateResponse = proxy.administrate(administrate); } catch (java.rmi.RemoteException e) { org.apache.axis.AxisFault l_fault = org.apache.axis.AxisFault.makeFault(e); System.out.println(l_fault.getFaultString()); System.out.println(l_fault.getFaultCode().toString()); org.w3c.dom.Element[] l_details = l_fault.getFaultDetails(); return false; } return true; }
public GetPageCountResponse getPageCount(String name, String id) { ObjectIdentifier objectIdentifier = new ObjectIdentifier(); objectIdentifier.setName(name); objectIdentifier.setId(id); GetPageCount getPageCount = new GetPageCount(); getPageCount.setObject(objectIdentifier); GetPageCountResponse getPageCountResponse = null; try { getPageCountResponse = proxy.getPageCount(getPageCount); } catch (RemoteException e) { e.printStackTrace(); } return getPageCountResponse; }
/** * Select files by fileSearch or name or nameList, exclusively. * * @param fileSearch * @param name * @param nameList * @return SelectFilesResponse */ public com.actuate.schemas.SelectFilesResponse selectFiles( com.actuate.schemas.FileSearch fileSearch, String name, ArrayOfString nameList) { if (null == authenticationId) login(); com.actuate.schemas.ArrayOfString resultDef = newArrayOfString( new String[] { "Description", "FileType", "Id", "Name", "Owner", "PageCount", "Size", "TimeStamp", "UserPermissions", "Version", "VersionName" }); com.actuate.schemas.SelectFiles selectFiles = new com.actuate.schemas.SelectFiles(); selectFiles.setResultDef(resultDef); if (fileSearch != null) selectFiles.setSearch(fileSearch); else if (name != null) selectFiles.setName(name); else if (nameList != null) selectFiles.setNameList(nameList); com.actuate.schemas.SelectFilesResponse selectFilesResponse = null; try { selectFilesResponse = proxy.selectFiles(selectFiles); com.actuate.schemas.ArrayOfFile itemList = selectFilesResponse.getItemList(); com.actuate.schemas.File[] files = itemList.getFile(); if (files != null) { for (int i = 0; i < files.length; i++) { printFile(System.out, files[i]); } } } catch (RemoteException e) { System.out.println("error !!!"); e.printStackTrace(); } return selectFilesResponse; }
/** * Select all users. * * @return SelectUsersResponse */ public SelectUsersResponse selectUsers() { com.actuate.schemas.ArrayOfString resultDef = newArrayOfString( new String[] { "Id", "Name", "Description", "IsLoginDisabled", "EmailAddress", "HomeFolder", "ViewPreference", "MaxJobPriority", "SuccessNoticeExpiration", "FailureNoticeExpiration", "SendNoticeForSuccess", "SendNoticeForFailure", "SendEmailForFailure", "SendEmailForSuccess", "AttachReportInEmail" }); com.actuate.schemas.UserSearch userSearch = new com.actuate.schemas.UserSearch(); com.actuate.schemas.SelectUsers selectUsers = new com.actuate.schemas.SelectUsers(); selectUsers.setResultDef(resultDef); selectUsers.setSearch(userSearch); com.actuate.schemas.SelectUsersResponse selectUsersResponse = null; try { selectUsersResponse = proxy.selectUsers(selectUsers); com.actuate.schemas.User[] users = selectUsersResponse.getUsers().getUser(); for (int i = 0; i < selectUsersResponse.getTotalCount().intValue(); i++) { System.out.println(users[i].getName()); } } catch (RemoteException e) { System.out.println("error !!!"); e.printStackTrace(); } return selectUsersResponse; }
/** * ExecuteReport using the information stored in this class: - jobName - inputFileName - * outputFileName * * @throws RemoteException */ public void executeReport() throws RemoteException { com.actuate.schemas.ExecuteReport executeReport = new com.actuate.schemas.ExecuteReport(); executeReport.setJobName(jobName); executeReport.setInputFileName(inputFileName); boolean bSaveOutputFile = (!outputFileName.equals("")); executeReport.setSaveOutputFile(new Boolean(bSaveOutputFile)); if (bSaveOutputFile) { com.actuate.schemas.NewFile requestedOutputFile = new com.actuate.schemas.NewFile(); requestedOutputFile.setName(outputFileName); executeReport.setRequestedOutputFile(requestedOutputFile); } com.actuate.schemas.ExecuteReportResponse executeReportResponse = proxy.executeReport(executeReport); System.out.println("Status " + executeReportResponse.getStatus()); }
/** * Login to actuate server with username and password to targetVolume Return true if login success */ public boolean login() { boolean success = true; com.actuate.schemas.Login request = new com.actuate.schemas.Login(); request.setPassword(password); request.setUser(username); try { actuateAPI.setAuthId(null); System.out.println("Setting TargetVolume to " + targetVolume); actuateAPI.setTargetVolume(targetVolume); com.actuate.schemas.LoginResponse response = proxy.login(request); authenticationId = response.getAuthId(); actuateAPI.setAuthId(authenticationId); } catch (java.rmi.RemoteException e) { // login failed success = false; } return success; }
/** * Download file from encyclopdia to the specified directory If document is decomposed ,multiple * attachments of files will be discarded as its not in viewable format.But attachments ids will * be shown to user.This example can be modified easily to save those attachments as different * files. * * @param FileName * @param decomposeCompoundDocument * @param downloadEmbedded * @param downloadDirectory * @return boolean */ public String downloadFile( String FileName, boolean decomposeCompoundDocument, boolean downloadEmbedded, String downloadDirectory) throws Exception { System.out.println("Download " + FileName); com.actuate.schemas.DownloadFile downloadFile = new com.actuate.schemas.DownloadFile(); downloadFile.setFileName(FileName); downloadFile.setDecomposeCompoundDocument(new Boolean(decomposeCompoundDocument)); downloadFile.setDownloadEmbedded(new Boolean(downloadEmbedded)); String downloadName = null; com.actuate.schemas.DownloadFileResponse downloadFileResponse = null; try { downloadFileResponse = proxy.downloadFile(downloadFile); String serverFilePath = downloadFileResponse.getFile().getName(); String localFileName = serverFilePath.substring(serverFilePath.lastIndexOf('/') + 1, serverFilePath.length()); if (!downloadEmbedded) { downloadName = saveNonEmbededResponse(downloadDirectory, localFileName, decomposeCompoundDocument); } else { downloadName = saveEmbededResponse( downloadDirectory, localFileName, downloadFileResponse, decomposeCompoundDocument); } } catch (SOAPException e) { throw AxisFault.makeFault(e); } catch (RemoteException e) { throw e; } catch (IOException e) { throw e; } return downloadName; }
/** * Select a single page and save the result in the specified directory * * @param FileName * @param format * @param pageNumber * @param downloadDirectory * @return String the first file attachment name * @throws RemoteException */ public String selectPage(String FileName, String format, int pageNumber, String downloadDirectory) throws RemoteException { // Set view parameter com.actuate.schemas.ViewParameter viewParameter = new com.actuate.schemas.ViewParameter(); viewParameter.setFormat(format); viewParameter.setUserAgent( "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.0.3705)"); // Set file name to view com.actuate.schemas.ObjectIdentifier objectIdentifier = new com.actuate.schemas.ObjectIdentifier(); objectIdentifier.setName(FileName); // Set the pages to view com.actuate.schemas.PageIdentifier pageIdentifier = new com.actuate.schemas.PageIdentifier(); pageIdentifier.setPageNum(new Long(pageNumber)); // Set the select page request com.actuate.schemas.SelectPage selectPage = new com.actuate.schemas.SelectPage(); selectPage.setObject(objectIdentifier); selectPage.setViewParameter(viewParameter); selectPage.setPage(pageIdentifier); selectPage.setDownloadEmbedded(new Boolean(true)); // Set FileType actuateAPI.setFileType(FileName.split("\\.")[1]); // SelectPage com.actuate.schemas.SelectPageResponse selectPageResponse = proxy.selectPage(selectPage); // Save the result in download directory new File(downloadDirectory).mkdir(); String firstAttachmentName = saveAttachment(selectPageResponse.getPageRef(), downloadDirectory); saveAttachment(selectPageResponse.getPostResponseRef(), downloadDirectory); return firstAttachmentName; }
/** * Method getFolderItems. Can be called repeatedly to use a fetch handle. * * @return GetFolderItemsResponse */ public GetFolderItemsResponse getFolderItems() { com.actuate.schemas.ArrayOfString resultDef = newArrayOfString( new String[] { "UserPermissions", "FileType", "Version", "Description", "VersionName", "Size", "PageCount", "TimeStamp", "Owner" }); com.actuate.schemas.GetFolderItems request = new com.actuate.schemas.GetFolderItems(); request.setFolderName(currentDirectory); request.setLatestVersionOnly(Boolean.FALSE); request.setResultDef(resultDef); com.actuate.schemas.FileSearch search = new com.actuate.schemas.FileSearch(); search.setFetchDirection(Boolean.TRUE); search.setFetchSize(getFolderItemsFetchSize); search.setFetchHandle(getFolderItemsFetchHandle); request.setSearch(search); com.actuate.schemas.GetFolderItemsResponse response = null; try { response = proxy.getFolderItems(request); getFolderItemsFetchHandle = response.getFetchHandle(); } catch (Exception e) { e.printStackTrace(); } return response; }