001/* 002 * (C) Copyright 2006-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 * bstefanescu 018 */ 019package org.nuxeo.connect.update.task.standalone.commands; 020 021import java.io.File; 022import java.util.Map; 023 024import org.nuxeo.connect.update.PackageException; 025import org.nuxeo.connect.update.ValidationStatus; 026import org.nuxeo.connect.update.task.Command; 027import org.nuxeo.connect.update.task.Task; 028import org.nuxeo.connect.update.xml.XmlWriter; 029import org.w3c.dom.Element; 030 031/** 032 * Install bundle, flush any application cache and perform Nuxeo preprocessing on the bundle. 033 * <p> 034 * The inverse of this command is Undeploy. 035 * 036 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 037 */ 038public class DeployConfigPlaceholder extends AbstractCommand { 039 040 public static final String ID = "deploy-config"; 041 042 protected File file; 043 044 public DeployConfigPlaceholder() { 045 super(ID); 046 } 047 048 public DeployConfigPlaceholder(File file) { 049 super(ID); 050 this.file = file; 051 } 052 053 @Override 054 protected void doValidate(Task task, ValidationStatus status) throws PackageException { 055 // do nothing 056 } 057 058 @Override 059 protected Command doRun(Task task, Map<String, String> prefs) throws PackageException { 060 // standalone mode: nothing to do 061 // XXX why not UndeployConfigPlaceholder ? 062 return new UndeployPlaceholder(file); 063 } 064 065 public void readFrom(Element element) throws PackageException { 066 String v = element.getAttribute("file"); 067 if (v.length() > 0) { 068 file = new File(v); 069 guardVars.put("file", file); 070 } 071 } 072 073 public void writeTo(XmlWriter writer) { 074 writer.start(ID); 075 if (file != null) { 076 writer.attr("file", file.getAbsolutePath()); 077 } 078 writer.end(); 079 } 080}