on 05-20-2022 5:05 PM
Hello We have a requirement update the host fingerprint key in Destination SFTP of multiple Crystal Reports 2016, Is this possible to achieve thru Rest or SDK? If yes can you any one provide details of the SDK.
Regards
Phani
I don't think this is possible in REST, but it's definitely possible using the Java SDK. Here's the logic for it:
1. Log in to your system. I have a class I've created that has functions to handle all of the interaction with BOBJ - this way, when we update BOBJ, I only have to change code in one place, if there are required code changes, and then recompile all of my programs instead of having to go into each program to search for and make, potentially, multiple changes. I've pulled from that code to provide some simple login code for you:
private IEnterpriseSession logon(final String CMS, final String username, final password) throws SDKException {
IEnterpriseSession session = null;
SDKException lastException = null;
logger.debug("Starting Logon Process.");
try {
final ISessionMgr mgr = CrystalEnterprise.getSessionMgr();
return mgr.logon(username, password, CMS, "secEnterprise");
}
catch (final SDKException e) {
logger.debug("Execption caused by logon " + e.getMessage(), e);
session = null;
throw(e);
}
}
2. Get an IInfoStore so that you can query the CMS:
IInfoStore istore = (IInfoStore) entSession.getService("InfoStore");
3. There is no easy way to filter a CMS query to get just the reports that are going to an SFTP destination. You'll probably need to check both schedules and the default configuration of report templates (non-instances) to find the fingerprints you need to replace. If you have 1,000 or fewer schedules and 1,000 or fewer report templates, you can do something like the following:
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.occa.infostore.IDestination;
import com.crystaldecisions.sdk.occa.infostore.IDestinations;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.infostore.ISchedulingInfo;
import com.crystaldecisions.sdk.properties.IProperties;
public class SchedUpdater{
public void updateScheds(final IInfoStore istore, final String sftpServer, final String newFingerprint) {
IInfoObjects iobjs;
try {
//fix the schedules
iobjs = istore.query("Select SI_ID, SI_NAME, SI_SCHEDULEINFO from CI_INFOOBJECTS where SI_INSTANCE = 1 and SI_SCHEDULE_STATUS in (8, 9)");
if (iobjs != null) {
fixFingerprint(sftpServer, newFingerprint, iobjs);
istore.commit(iobjs);
}
//fix default properties on report templates
iobjs = istore.query("Select SI_ID, SI_NAME, SI_SCHEDULEINFO from CI_INFOOBJECTS where SI_KIND in ('Webi', 'CrystalReport') and SI_INSTANCE = 0");
if (iobjs != null) {
fixFingerprint(sftpServer, newFingerprint, iobjs);
istore.commit(iobjs);
}
} catch (SDKException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void fixFingerprint(String sftpServer, String newFingerprint, IInfoObjects iobjs) throws SDKException {
for (Object iobj : iobjs) {
IInfoObject rpt = (IInfoObject) iobj;
ISchedulingInfo si = rpt.getSchedulingInfo();
IDestinations dests = si.getDestinations();
for (Object dobj : dests) {
IDestination dest = (IDestination) dobj;
final String destStr = dest.getName();
if (destStr.equals("CrystalEnterprise.Sftp")){
//We have an SFTP destination.
IProperties ip = dest.properties();
IProperties dprops = ip.getProperties("SI_DEST_SCHEDULEOPTIONS");
String svrName = dprops.getString("SI_SERVER_NAME");
if (svrName.equals(sftpServer)) {
dprops.setProperty("SI_SFTP_FINGERPRINT", newFingerprint);
rpt.save();
}
}
}
}
}
}
If you have more than 1,000 schedules or report templates, you'll either 1. Change the queries in the code above to start with "Select Top <nnnnn> " where <nnnnn> is the maximum number of objects of either type. However, if you have tens of thousands of objects, this is going to be slow and the queries might time-out.2. If you have tens of thousands of objects, you'll need to use recursion to walk down through the public and favorites folders to check each report and its instances. I can walk you through this if it's necessary.-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.