importintradoc.common.DataStreamWrapper;importintradoc.common.ServiceException;importintradoc.data.DataException;importintradoc.data.DataResultSet;importintradoc.server.FileService;importintradoc.server.ServiceData;importjava.io.IOException;importjava.util.Vector;importziprenditions.ZipRenditionsHandler;import staticintradoc.common.LocaleResources.getString;import staticintradoc.server.ServiceManager.createService;import staticintradoc.server.ServiceManager.getFullService;/** * @author Jonathan Hult */// Class needed so we can override default functionality of GET_ZIP_BUNDLE// This class should be used as a ServiceHandler for a new servicepublicclassZipRenditionsHandlerExtendedextendsZipRenditionsHandler{privatefinalStringTRACE_SECTION="ZipRenditionsHandlerExtended";// Remove zipFilePath from temp files; otherwise, this gets removed during service.cleanUp// Add zipFilePath to LocalData so we can easily fetch if from other ServiceHandlerpublicvoidcreateRenditionBundleExtended()throwsDataException,ServiceException{super.createRenditionBundle();finalDataStreamWrapperstreamWrapper=m_service.getDownloadStream(false);finalStringzipFilePath=streamWrapper.m_filePath;Report.trace(TRACE_SECTION,"zipFilePath: "+zipFilePath,null);if(hasText(zipFilePath)){m_binder.putLocal("zipFilePath",zipFilePath);m_binder.m_tempFiles.remove(zipFilePath);}else{Report.trace(TRACE_SECTION,"Could not find zip path",null);Report.trace(TRACE_SECTION,"DataBinder: "+m_binder.getLocalData().toString(),null);thrownewServiceException(getString("FailureCreatingZip_StrResource",m_service));}}publicvoidcreateResultSetFromParamListExtended()throwsDataException,ServiceException{super.createResultSetFromParamList();}/** * Override to alter entries to change pkgEntryName (used as file name in zip). * * @param service * @param entries * @param fileSizeTotal * @throws IOException * @throws DataException * @throws ServiceException */@OverridepublicvoidaddEntry(FileServiceservice,Vectorentries,long[]fileSizeTotal)throwsIOException,DataException,ServiceException{//super.addEntry(service, entries, fileSizeTotal);for(int=0;i<entries.size();i++){ObjectfileName=entries.get(i);// do logic to alter file nameStringfileNameModified=((String)fileName).toUpperCase();// Set new file name in vectorvector.set(i,fileNameModified);}}// Pass in UserData - this is missing in Oracle's code and causes major problems@OverridepublicFileServicecreateAndExecuteService(finalStringcommand)throwsDataException,ServiceException{finalServiceDataserviceData=getFullService(command);finalFileServiceservice=(FileService)createService(serviceData.m_classID,m_workspace,m_service.getOutput(),m_binder,serviceData);service.setConditionVar("ForceDownloadStreamToFilepath",true);service.initDelegatedObjects();m_service.getRequestImplementor().doRequestInternalEx(service,m_service.getUserData(),false);returnservice;}}
Comments (4)
Dharmendra Kumar
Hi Hult,
I putted your code in Jdeveloper IDE and add library in IDE like idcserver.jar, classes-ZipRenditionManagement.jar and other WCC jars, but in line 30 trace("zipFilePath: " + zipFilePath); in line 32 hasText(zipFilePath), line 36 nd 37 trace("Could not find zip path"); trace("DataBinder: " + m_binder.getLocalData().toString()); line 64 String fileNameModified = fileName.toUpperCase(); method not found error message see on JDev and at line 67 vector.set(i, fileNameModified); vector variable not found error message is seen.
I think trace() method is not belong to any java package and it is printStackTrace method, Please clear it. and will be appreciable if I get correct code for try service handler I am using this first time . Also when I changed vector with Vector then I get error in set() method.
Thanks
Dharmendra
Jonathan Hult
I updated the code to be more verbose.
For hasText(), you need a library such as one of the following:
Or just re-write that statement as a null and non-empty check.
Dharmendra Kumar
Hi Jonathan,
Thanks for refine code, Now I want to tell to you how I am using this code. I create a custom component in which I am using static resource with merge Service handler in serviceName I give the FileService and Handler name the class name, Also add service GET_ZIP_BUNDLE. I put class ZipRenditionsHandlerExtended in classes folder of the component and related library in lib folder. When I run the service using RIDC from a java app the I got the error as added in community thread https://community.oracle.com/thread/3958774 . Now want to know what mistake i made to build the component in result I am getting error, will be appreciable if you guide me on it. Also I have some questions in community thread.
Hi Hult,
I putted your code in Jdeveloper IDE and add library in IDE like idcserver.jar, classes-ZipRenditionManagement.jar and other WCC jars, but in line 30 trace("zipFilePath: " + zipFilePath); in line 32 hasText(zipFilePath), line 36 nd 37 trace("Could not find zip path"); trace("DataBinder: " + m_binder.getLocalData().toString()); line 64 String fileNameModified = fileName.toUpperCase(); method not found error message see on JDev and at line 67 vector.set(i, fileNameModified); vector variable not found error message is seen.
I think trace() method is not belong to any java package and it is printStackTrace method, Please clear it. and will be appreciable if I get correct code for try service handler I am using this first time . Also when I changed vector with Vector then I get error in set() method.
Thanks Dharmendra
I updated the code to be more verbose.
For hasText(), you need a library such as one of the following:
Or just re-write that statement as a null and non-empty check.
Hi Jonathan,
Thanks for refine code, Now I want to tell to you how I am using this code. I create a custom component in which I am using static resource with merge Service handler in serviceName I give the FileService and Handler name the class name, Also add service GET_ZIP_BUNDLE. I put class ZipRenditionsHandlerExtended in classes folder of the component and related library in lib folder. When I run the service using RIDC from a java app the I got the error as added in community thread https://community.oracle.com/thread/3958774 . Now want to know what mistake i made to build the component in result I am getting error, will be appreciable if you guide me on it. Also I have some questions in community thread.
Thanks You dharmendra
component is here https://bitbucket.org/Dharmendra-Kumar/zip/downloads/SHTEST.zip