Jump to content
We've recently updated our Privacy Statement, available here ×

Get all reports of a particular folder


ncheruku

Recommended Posts

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

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

 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

 

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

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

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

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

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

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

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

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...