Search in sources :

Example 16 with HttpActionContext

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());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpActionContext(it.cnr.jada.action.HttpActionContext) BigInteger(java.math.BigInteger) ArchiviaStampaPdgVariazioneBulk(it.cnr.contab.pdg00.bulk.ArchiviaStampaPdgVariazioneBulk)

Example 17 with HttpActionContext

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());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpActionContext(it.cnr.jada.action.HttpActionContext) BigInteger(java.math.BigInteger) ArchiviaStampaPdgVariazioneBulk(it.cnr.contab.pdg00.bulk.ArchiviaStampaPdgVariazioneBulk)

Example 18 with HttpActionContext

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));
}
Also used : UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) ComponentException(it.cnr.jada.comp.ComponentException) CdrBulk(it.cnr.contab.config00.sto.bulk.CdrBulk)

Example 19 with HttpActionContext

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();
}
Also used : UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) CdrBulk(it.cnr.contab.config00.sto.bulk.CdrBulk)

Example 20 with HttpActionContext

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);
    }
}
Also used : SocketException(java.net.SocketException) Blob(java.sql.Blob) HomeCache(it.cnr.jada.persistency.sql.HomeCache) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Connection(java.sql.Connection) BulkHome(it.cnr.jada.bulk.BulkHome) Bframe_blob_tipoKey(it.cnr.jada.blobs.bulk.Bframe_blob_tipoKey) Bframe_blob_tipoBulk(it.cnr.jada.blobs.bulk.Bframe_blob_tipoBulk) HttpActionContext(it.cnr.jada.action.HttpActionContext) Bframe_blobBulk(it.cnr.jada.blobs.bulk.Bframe_blobBulk) Bframe_blobKey(it.cnr.jada.blobs.bulk.Bframe_blobKey) Clob(java.sql.Clob)

Aggregations

HttpActionContext (it.cnr.jada.action.HttpActionContext)31 HttpServletResponse (javax.servlet.http.HttpServletResponse)12 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)11 BigInteger (java.math.BigInteger)11 StorageObject (it.cnr.si.spring.storage.StorageObject)10 RemoteException (java.rmi.RemoteException)10 ComponentException (it.cnr.jada.comp.ComponentException)9 OutputStream (java.io.OutputStream)9 ApplicationException (it.cnr.jada.comp.ApplicationException)7 UserContext (it.cnr.jada.UserContext)6 InputStream (java.io.InputStream)6 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)5 DocumentiContabiliService (it.cnr.contab.doccont00.service.DocumentiContabiliService)5 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)5 CNRUserContext (it.cnr.contab.utenze00.bp.CNRUserContext)5 ActionContext (it.cnr.jada.action.ActionContext)5 ServletException (javax.servlet.ServletException)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 StreamSource (javax.xml.transform.stream.StreamSource)5 V_mandato_reversaleBulk (it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk)4