001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thierry Delprat 018 */ 019package org.nuxeo.ecm.webapp.tree; 020 021import java.io.IOException; 022import java.io.Serializable; 023 024import javax.faces.context.FacesContext; 025import javax.servlet.http.HttpServletResponse; 026 027import org.jboss.seam.annotations.Install; 028import org.jboss.seam.annotations.Name; 029import org.jboss.seam.annotations.Scope; 030 031import static org.jboss.seam.ScopeType.SESSION; 032 033@Name("treeInvalidator") 034@Scope(SESSION) 035@Install(precedence = Install.FRAMEWORK) 036public class TreeInvalidatorBean implements Serializable { 037 038 private static final long serialVersionUID = 1L; 039 040 protected boolean needsInvalidation = false; 041 042 public String forceTreeRefresh() throws IOException { 043 044 needsInvalidation = true; 045 046 FacesContext context = FacesContext.getCurrentInstance(); 047 HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); 048 response.setContentType("application/xml; charset=UTF-8"); 049 response.getWriter().write("<response>OK</response>"); 050 context.responseComplete(); 051 052 return null; 053 } 054 055 public boolean needsInvalidation() { 056 return needsInvalidation; 057 } 058 059 public void invalidationDone() { 060 needsInvalidation = false; 061 } 062 063}