import oracle.stellent.ridc.convenience.adf.connection.AdfConnectionFacade;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.protocol.ServiceResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import oracle.adf.share.logging.ADFLogger;
private static ADFLogger log= ADFLogger.createADFLogger(getFile.class);
public void getFile(FacesContext context,OutputStream outputStream) {
try {
IdcClientManager manager = new IdcClientManager();
AdfConnectionFacade facade = new AdfConnectionFacade("UcmConnection");
IdcClient idcClient = facade.getIdcClient();
IdcContext userContext;
if(adfCtx.getSessionScope().get("IdcContext")==null) {
userContext = new IdcContext(facade.getUserCredentials("user"));
adfCtx.getSessionScope().put("IdcContext",userContext);
}
else {
userContext=(IdcContext)adfCtx.getSessionScope().get("IdcContext");
}
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_FILE");
dataBinder.putLocal("dID",docID);
responseString =idcClient.sendRequest(userContext, dataBinder);
InputStream inputStream = responseString.getResponseStream();
byte[] buf = new byte[1024 * 256];
long i = 0;
int len;
log.severe("Downloading File from UCM Server");
while (true) {
i++;
len = inputStream.read(buf);
if (len == -1) {
break;
}
outputStream.write(buf, 0, len);
}
outputStream.flush();
inputStream.close();
outputStream.close();
context.responseComplete();
} catch (IdcClientException ice) {
log.severe("IDC Client Exception occured. Exception message: " + ice.getMessage());
} catch (IOException ioe) {
log.severe("IO Exception occurred. Unable to retrieve file. Message: " + ioe.getMessage());
} catch (Exception ex) {
log.severe("Exception message: " + ex.getMessage() );
}
}
}
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.protocol.ServiceResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import oracle.adf.share.logging.ADFLogger;
private static ADFLogger log= ADFLogger.createADFLogger(getFile.class);
public void getFile(FacesContext context,OutputStream outputStream) {
try {
IdcClientManager manager = new IdcClientManager();
AdfConnectionFacade facade = new AdfConnectionFacade("UcmConnection");
IdcClient idcClient = facade.getIdcClient();
IdcContext userContext;
if(adfCtx.getSessionScope().get("IdcContext")==null) {
userContext = new IdcContext(facade.getUserCredentials("user"));
adfCtx.getSessionScope().put("IdcContext",userContext);
}
else {
userContext=(IdcContext)adfCtx.getSessionScope().get("IdcContext");
}
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_FILE");
dataBinder.putLocal("dID",docID);
responseString =idcClient.sendRequest(userContext, dataBinder);
InputStream inputStream = responseString.getResponseStream();
byte[] buf = new byte[1024 * 256];
long i = 0;
int len;
log.severe("Downloading File from UCM Server");
while (true) {
i++;
len = inputStream.read(buf);
if (len == -1) {
break;
}
outputStream.write(buf, 0, len);
}
outputStream.flush();
inputStream.close();
outputStream.close();
context.responseComplete();
} catch (IdcClientException ice) {
log.severe("IDC Client Exception occured. Exception message: " + ice.getMessage());
} catch (IOException ioe) {
log.severe("IO Exception occurred. Unable to retrieve file. Message: " + ioe.getMessage());
} catch (Exception ex) {
log.severe("Exception message: " + ex.getMessage() );
}
}
}
how to get file content Type while downloading?
ReplyDeleteYou can try following code snippet:
DeleteresponseString =idcClient.sendRequest(userContext, dataBinder);
String contentType = responseString.getHeader("Content-Type");
InputStream inputStream = responseString.getResponseStream();
Rgds,
W!nkle
how to download multiple files from server?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi,i am trying to upload a file to UCM ,all file types and of different size are getting uploaded except doc or docx file type having size less than 100kb more than 100kb are getting successfully uploaded.Pls can anyone suggest me the solution for it.
ReplyDeleteThanks
Why do you want to disable select on the blog?
ReplyDeleteHow can we download expired content?
ReplyDelete