ncheruku Posted August 25, 2009 Share Posted August 25, 2009 Hi,I am newbie to Jasper reports.I have a requirement where I need to get all the reports of a particular folder at a time through the one of the repository web service methods.Can you please let me know how I need to proceed as I did not find a specific method to do so.The runReport method gets only one report ,get method gives all the resources including sources in folders including children but not all the reports.So can anybody please let me know there must be a mechanism in whihch we can acess all the reports at a time.I am thinking of going with list method with wstype="content resource".Can you please let me know if this works....The same thing for all the schedule jobs at a time...Thanks in advance.. Nithin Link to comment Share on other sites More sharing options...
ldangelo Posted August 26, 2009 Share Posted August 26, 2009 Here is some code that should help you out....Code:package com.mpower.service;import java.util.List;public interface JasperServerService { List list(String dir) throws Exception; void setPassword(String pass); String getPassword(); void setUserName(String username); String getUserName(); void setURI(String URI); String getURI();}package com.mpower.service;import java.util.List;import org.springframework.stereotype.Service;import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor;import com.jaspersoft.jasperserver.irplugin.JServer;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;//@Service("jasperServerService")public class JasperServerServiceImpl implements JasperServerService { protected final Log logger = LogFactory.getLog(getClass()); private String userName; private String password; private String uri; private JServer jserver; @Override public String getPassword() { return password; } @Override public String getURI() { return uri; } @Override public String getUserName() { return userName; } @Override public List list(String dir) throws Exception { logger.info("list(" + dir + ")"); jserver = new JServer(); jserver.setUsername(userName); jserver.setPassword(password); jserver.setUrl(uri); ResourceDescriptor rd = new ResourceDescriptor(); rd.setWsType(ResourceDescriptor.TYPE_FOLDER); rd.setUriString(dir); return jserver.getWSClient().list(rd); } @Override public void setPassword(String pass) { logger.info("setPassword(" + pass + ")"); password = pass; } @Override public void setURI(String URI) { logger.info("setURI(" + URI + ")"); uri = URI; } @Override public void setUserName(String username) { logger.info("setUserName(" + username + ")"); userName = username; } } Link to comment Share on other sites More sharing options...
ncheruku Posted August 28, 2009 Author Share Posted August 28, 2009 rd.setWsType(ResourceDescriptor.TYPE_FOLDER); rd.setUriString(dir); Does the above code returns a List of resource descriptors or published reports in that folder.Because the webservices documentation it is mentioned that the list method returns a list of resource definitions but not the reports in that folder...Can you please clarify this for me...... Link to comment Share on other sites More sharing options...
lucianc Posted August 31, 2009 Share Posted August 31, 2009 The list operation returns a list of all resources in a repository folder. Reports are a type of resources, so the reports in the folder will be included in the returned list.If you only want to list reports, you can use the WSClient.listResourcesInFolder method (introduces in 3.5, see the Web Services Guide for details).Regards,Lucian Link to comment Share on other sites More sharing options...
ncheruku Posted August 31, 2009 Author Share Posted August 31, 2009 Hi,I dont find the listResourcesInFolder(String type, String parentFolder, String ancestorFolder) method in jasperserver-ireport-plugin-2.1.0.jar.I found this jar in JasperServer 3.5.Can you please tell me where I can download a latest version of iReport plugin jar whihc includes the above method... ThanksNithin Link to comment Share on other sites More sharing options...
ncheruku Posted August 31, 2009 Author Share Posted August 31, 2009 Hi, I dont find the listResourcesInFolder(String type, String parentFolder, String ancestorFolder) method in jasperserver-ireport-plugin-2.1.0.jar.I found this jar in JasperServer 3.5.Can you please tell me where I can download a latest version of iReport plugin jar whihc includes the above method... Thanks Nithin Link to comment Share on other sites More sharing options...
ncheruku Posted August 31, 2009 Author Share Posted August 31, 2009 Hi, The listResources(String type,String parentFolder, String ancestorFolder) doe not appear in the JasperServer-iReport-plugin jar in either 2.0.1 or 3.00 jar download.And also if I try to use the method by copying manually the addArgument method got replaced with the setArgument and accepts only list as the parameter.So can you please tell if I can get a different route for this to call the setArgument method in the com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.Request; API I would really aprecite for a quick response....... req.addArgument(Argument.LIST_RESOURCES); req.addArgument(Argument.RESOURCE_TYPE, type); protected List listResources(String type, String parentFolder, String ancestorFolder) throws Exception { Request req = new Request(); req.setOperationName(Request.OPERATION_LIST); req.setLocale(getServer().getLocale()); req.addArgument(Argument.LIST_RESOURCES); req.addArgument(Argument.RESOURCE_TYPE, type); if (parentFolder != null) { req.addArgument(Argument.PARENT_DIRECTORY, parentFolder); } else if (ancestorFolder != null) { req.addArgument(Argument.START_FROM_DIRECTORY, ancestorFolder); } StringWriter xmlStringWriter = new StringWriter(); Marshaller.marshal(req, xmlStringWriter); return list(xmlStringWriter.toString()); } Link to comment Share on other sites More sharing options...
lucianc Posted September 1, 2009 Share Posted September 1, 2009 The fact that jasperserver-ireport-plugin-2.1.0.jar is shipped with JS 3.5.0 is indeed a problem. We'll fix that in the next release.In the meantime, you can replace the addArgument() calls by req.getArguments().add(new Argument(argumentName, value)). You can use null as value if the argument does not expect a value (e.g. Argument.LIST_RESOURCES).Regards,Lucian Link to comment Share on other sites More sharing options...
tkavanagh Posted September 3, 2009 Share Posted September 3, 2009 Ug, that's bad that the java-webapp-sample has an old jar. I just created bug Tracker item 4275 to address this issue. This will get cleaned up for the 4.0 (I think that will be the number) release which is due in the late fall. Also, as a quick workaround... You can get the most current ireport-plugin jar from the ireport download. Also, the correct ireport-plugin.jar is included in the installer (when you choose to install ireport as part of the installation). For all the other jars found in java-webapp-sample/WEB-INF/lib, you can copy the most current jars from jasperserver/WEB-INF/lib (ie you 3.5.0 instance). This will get you all the most current dependencies. Link to comment Share on other sites More sharing options...
Sakura Hana Posted March 11, 2014 Share Posted March 11, 2014 can you share your code regarding to get only one report from JasperReports Server? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now