001/* 002 * Copyright 2016 Anyware Services 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 */ 016package org.ametys.web.live; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import org.apache.commons.lang.StringUtils; 022import org.quartz.JobExecutionContext; 023 024import org.ametys.core.observation.Observer; 025import org.ametys.core.schedule.Schedulable; 026import org.ametys.runtime.config.Config; 027import org.ametys.runtime.i18n.I18nizableText; 028 029/** 030 * A {@link Schedulable} job which rebuild and populate the live workspace. 031 * This ensures data integrity inside the live workspace if by mistake 032 * synchronization {@link Observer}s fails to update the live workspace. 033 */ 034public class RebuildLiveAllWorkspaceSchedulable extends AbstractRebuildLiveWorkspaceSchedulable 035{ 036 @Override 037 protected void _initializeErrorMail(JobExecutionContext context) 038 { 039 __ERROR_MAIL_SUBJECT = new I18nizableText("plugin.web", "PLUGINS_WEB_BUILDALL_ERROR_MAIL_SUBJECT"); 040 041 String cmsUrl = StringUtils.stripEnd(StringUtils.removeEndIgnoreCase(Config.getInstance().getValueAsString("cms.url"), "index.html"), "/"); 042 String url = cmsUrl + "/_admin/"; 043 044 List<String> i18nParams = new ArrayList<>(); 045 i18nParams.add(url); 046 __ERROR_MAIL_BODY = new I18nizableText("plugin.web", "PLUGINS_WEB_BUILDALL_ERROR_MAIL_BODY", i18nParams); 047 } 048 049 @Override 050 protected void _doExecute(JobExecutionContext context) throws Exception 051 { 052 _rebuildLiveComponent.rebuildLiveWorkspace(); 053 } 054}