use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.
the class FirmaDigitalePdgVariazioniBP method scaricaFileGenerico.
public void scaricaFileGenerico(ActionContext actioncontext) throws IOException, ServletException {
ArchiviaStampaPdgVariazioneBulk archiviaStampaPdgVariazioneBulk = (ArchiviaStampaPdgVariazioneBulk) getFocusedElement();
InputStream is = null;
final HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
if (!isTestSession()) {
is = pdgVariazioniService.getResource(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject());
response.setContentType(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject().getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
response.setContentLength(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject().<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
} else {
is = new BufferedInputStream(new FileInputStream(nomeFilePathTest));
}
IOUtils.copyLarge(is, response.getOutputStream());
}
use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.
the class FirmaDigitalePdgVariazioniBP method scaricaFile.
public void scaricaFile(ActionContext actioncontext) throws IOException, ServletException {
ArchiviaStampaPdgVariazioneBulk archiviaStampaPdgVariazioneBulk = (ArchiviaStampaPdgVariazioneBulk) getFocusedElement();
InputStream is = null;
final HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
if (!isTestSession()) {
is = pdgVariazioniService.getResource(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject());
response.setContentType(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject().getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
response.setContentLength(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument().getStorageObject().<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
} else {
is = new BufferedInputStream(new FileInputStream(nomeFilePathTest));
}
IOUtils.copyLarge(is, response.getOutputStream());
}
use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.
the class SelezionatoreUnitaOrganizzativaBP method selezionaUO.
public void selezionaUO(ActionContext context, Integer esercizio, Unita_organizzativaBulk uo, CdrBulk cdr) throws ComponentException, RemoteException, EJBException, BusinessProcessException {
GestioneUtenteBP bp = (GestioneUtenteBP) context.getBusinessProcess("/GestioneUtenteBP");
if (esercizio != null)
((CNRUserInfo) getUserInfo()).setEsercizio(esercizio);
if (uo != null) {
getUserInfo().setUnita_organizzativa(uo);
if (cdr == null)
cdr = (CdrBulk) getComponentSession().cdrDaUo(context.getUserContext(), uo);
}
if (cdr != null)
getUserInfo().setCdr(cdr);
CNRUserInfo userInfo = (CNRUserInfo) getUserInfo();
UserContext userContext = new CNRUserContext(userInfo.getUtente().getCd_utente(), context.getSessionId(), userInfo.getEsercizio(), userInfo.getUnita_organizzativa().getCd_unita_organizzativa(), userInfo.getUnita_organizzativa().getCd_unita_padre(), userInfo.getCdr().getCd_centro_responsabilita());
if (context instanceof HttpActionContext) {
it.cnr.contab.utenze00.action.GestioneUtenteAction.getComponentSession().registerUser(userContext, context.getApplicationId());
// Remmato Marco Spasiano 28/02/2006 per problema di sessioni attive
// UnregisterUser.registerUnregisterUser((HttpActionContext)context);
}
try {
SessionTraceBulk sessionTrace = (SessionTraceBulk) createCRUDComponentSession().inizializzaBulkPerModifica(userContext, new SessionTraceBulk(userContext.getSessionId()));
sessionTrace.setCd_cds(CNRUserContext.getCd_cds(userContext));
sessionTrace.setToBeUpdated();
createCRUDComponentSession().modificaConBulk(context.getUserContext(), sessionTrace);
} catch (Exception e) {
}
bp.setUserInfo((CNRUserInfo) getUserInfo());
context.setUserInfo(bp.getUserInfo());
context.setUserContext(userContext);
bp.setRadiceAlbero_main(context, getComponentSession().generaAlberoPerUtente(context.getUserContext(), bp.getUserInfo().getUtente(), uo.getCd_unita_organizzativa(), null, (short) 0));
}
use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.
the class SelezionatoreCdrBP method selezionaCdr.
public void selezionaCdr(ActionContext context) throws ComponentException, RemoteException, EJBException, BusinessProcessException {
CdrBulk cdr = (it.cnr.contab.config00.sto.bulk.CdrBulk) getFocusedElement();
GestioneUtenteBP bp = (GestioneUtenteBP) context.getBusinessProcess("/GestioneUtenteBP");
getUserInfo().setCdr(cdr);
CNRUserInfo userInfo = (CNRUserInfo) getUserInfo();
UserContext userContext = new CNRUserContext(userInfo.getUtente().getCd_utente(), context.getSessionId(), userInfo.getEsercizio(), userInfo.getUnita_organizzativa().getCd_unita_organizzativa(), userInfo.getUnita_organizzativa().getCd_unita_padre(), userInfo.getCdr().getCd_centro_responsabilita());
if (context instanceof HttpActionContext) {
it.cnr.contab.utenze00.action.GestioneUtenteAction.getComponentSession().registerUser(userContext, context.getApplicationId());
// Remmato Marco Spasiano 28/02/2006 per problema di sessioni attive
// UnregisterUser.registerUnregisterUser((HttpActionContext)context);
}
bp.setUserInfo((CNRUserInfo) getUserInfo());
context.setUserInfo(bp.getUserInfo());
context.setUserContext(userContext);
bp.setRadiceAlbero_main(context, getComponentSession().generaAlberoPerUtente(context.getUserContext(), bp.getUserInfo().getUtente(), bp.getUserInfo().getUnita_organizzativa().getCd_unita_organizzativa(), null, (short) 0));
context.closeBusinessProcess();
}
use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.
the class DownloadBlobServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpActionContext context = new HttpActionContext(this, request, response);
try {
Connection conn = EJBCommonServices.getConnection(context);
try {
InputStream is;
int bufferSize;
String fullpath = request.getPathInfo();
HomeCache homeCache = new HomeCache(conn);
String tipo = fullpath.substring(1, fullpath.indexOf('/', 1));
String filename = fullpath.substring(fullpath.lastIndexOf('/') + 1);
String path = fullpath.substring(fullpath.indexOf('/', 1) + 1, fullpath.lastIndexOf('/') + 1);
BulkHome home = (BulkHome) homeCache.getHome(it.cnr.jada.blobs.bulk.Bframe_blobBulk.class);
Bframe_blob_tipoBulk blob_tipo = (Bframe_blob_tipoBulk) homeCache.getHome(it.cnr.jada.blobs.bulk.Bframe_blob_tipoBulk.class).findByPrimaryKey(new Bframe_blob_tipoKey(tipo));
if (blob_tipo == null) {
response.sendError(404, fullpath);
return;
}
Bframe_blobBulk blob_bulk = (Bframe_blobBulk) home.findByPrimaryKey(new Bframe_blobKey(tipo, filename, path));
if (blob_bulk == null) {
response.sendError(404, fullpath);
return;
}
if (blob_bulk.getStato() != null && !"S".equals(blob_bulk.getStato())) {
response.sendError(404, fullpath);
return;
}
if (blob_tipo.getFl_binario().booleanValue()) {
Blob blob = home.getSQLBlob(blob_bulk, "BDATA");
bufferSize = Long.valueOf(blob.length()).intValue();
response.setBufferSize(bufferSize);
String contentType = getServletContext().getMimeType(filename);
if (contentType != null)
response.setContentType(contentType);
else
response.setContentType("www/unknown");
long length = blob.length();
if (length > 0L && length < 0x7fffffffL)
response.setContentLength((int) length);
is = blob.getBinaryStream();
} else {
Clob clob = home.getSQLClob(blob_bulk, "CDATA");
bufferSize = Long.valueOf(clob.length()).intValue();
response.setBufferSize(bufferSize);
String contentType = getServletContext().getMimeType(filename);
if (contentType != null)
response.setContentType(contentType);
else
response.setContentType("www/unknown");
long length = clob.length();
// if(length > 0L && length < 0x7fffffffL)
response.setContentLength((int) length);
is = clob.getAsciiStream();
}
response.setDateHeader("Last-Modified", blob_bulk.getDuva().getTime());
OutputStream os = response.getOutputStream();
try {
byte[] buffer = new byte[bufferSize];
int size;
while ((size = is.read(buffer)) > 0) os.write(buffer, 0, size);
} catch (SocketException ex) {
} finally {
is.close();
}
} finally {
conn.commit();
conn.close();
conn = null;
}
} catch (Throwable _ex) {
response.sendError(500);
}
}
Aggregations