Search in sources :

Example 6 with AbstractActiveSolutionHandler

use of com.servoy.j2db.AbstractActiveSolutionHandler in project servoy-client by Servoy.

the class AngularIndexPageWriter method getFlattenedSolution.

private static Pair<FlattenedSolution, Boolean> getFlattenedSolution(String solutionName, String clientnr, HttpServletRequest request, HttpServletResponse response) {
    INGClientWebsocketSession wsSession = null;
    HttpSession httpSession = request.getSession(false);
    if (clientnr != null && httpSession != null) {
        wsSession = (INGClientWebsocketSession) WebsocketSessionManager.getSession(CLIENT_ENDPOINT, httpSession, Integer.parseInt(clientnr));
    }
    FlattenedSolution fs = null;
    boolean closeFS = false;
    if (wsSession != null) {
        fs = wsSession.getClient().getFlattenedSolution();
    }
    if (fs == null) {
        try {
            closeFS = true;
            IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
            if (applicationServerUnavailable(response, as)) {
                return new Pair<FlattenedSolution, Boolean>(null, Boolean.FALSE);
            }
            SolutionMetaData solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(solutionName, SOLUTIONS);
            if (solutionMissing(response, solutionName, solutionMetaData)) {
                return new Pair<FlattenedSolution, Boolean>(null, Boolean.FALSE);
            }
            fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {

                @Override
                public IRepository getRepository() {
                    return ApplicationServerRegistry.get().getLocalRepository();
                }
            });
        } catch (Exception e) {
            Debug.error("error loading solution: " + solutionName + " for clientnr: " + clientnr, e);
        }
    }
    return new Pair<FlattenedSolution, Boolean>(fs, Boolean.valueOf(closeFS));
}
Also used : AbstractActiveSolutionHandler(com.servoy.j2db.AbstractActiveSolutionHandler) HttpSession(javax.servlet.http.HttpSession) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IApplicationServer(com.servoy.j2db.server.shared.IApplicationServer) SolutionMetaData(com.servoy.j2db.persistence.SolutionMetaData) ServletException(javax.servlet.ServletException) JSONException(org.json.JSONException) IOException(java.io.IOException) Pair(com.servoy.j2db.util.Pair)

Example 7 with AbstractActiveSolutionHandler

use of com.servoy.j2db.AbstractActiveSolutionHandler in project servoy-client by Servoy.

the class MediaResourcesServlet method sendFlattenedSolutionBasedMedia.

private boolean sendFlattenedSolutionBasedMedia(HttpServletRequest request, HttpServletResponse response, String rootSolutionName, String mediaName) throws IOException {
    FlattenedSolution fs = null;
    try {
        IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
        SolutionMetaData solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(rootSolutionName, IRepository.SOLUTIONS);
        if (solutionMetaData == null) {
            Debug.error("Solution '" + rootSolutionName + "' was not found when sending media data for '" + mediaName + "'.");
            return false;
        }
        fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {

            @Override
            public IRepository getRepository() {
                return ApplicationServerRegistry.get().getLocalRepository();
            }
        });
    } catch (RepositoryException e) {
        Debug.error(e);
    }
    try {
        return findAndSendMediaData(request, response, mediaName, fs);
    } finally {
        fs.close(null);
    }
}
Also used : AbstractActiveSolutionHandler(com.servoy.j2db.AbstractActiveSolutionHandler) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IApplicationServer(com.servoy.j2db.server.shared.IApplicationServer) RepositoryException(com.servoy.j2db.persistence.RepositoryException) SolutionMetaData(com.servoy.j2db.persistence.SolutionMetaData)

Aggregations

AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)7 IApplicationServer (com.servoy.j2db.server.shared.IApplicationServer)6 IRepository (com.servoy.j2db.persistence.IRepository)4 SolutionMetaData (com.servoy.j2db.persistence.SolutionMetaData)4 IOException (java.io.IOException)3 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 Pair (com.servoy.j2db.util.Pair)2 ArrayList (java.util.ArrayList)2 ServletException (javax.servlet.ServletException)2 HttpSession (javax.servlet.http.HttpSession)2 JSONException (org.json.JSONException)2 FormController (com.servoy.j2db.FormController)1 IApplication (com.servoy.j2db.IApplication)1 IForm (com.servoy.j2db.IForm)1 IFormUIInternal (com.servoy.j2db.IFormUIInternal)1 Field (com.servoy.j2db.persistence.Field)1 Form (com.servoy.j2db.persistence.Form)1 IRootObject (com.servoy.j2db.persistence.IRootObject)1 Media (com.servoy.j2db.persistence.Media)1