mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-02 17:35:18 +00:00
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4868 svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4869 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4904 svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4938 . Module management support Modularization of Records Management git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4956 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
130 lines
3.9 KiB
Java
130 lines
3.9 KiB
Java
/*
|
|
* Copyright (C) 2005 Alfresco, Inc.
|
|
*
|
|
* Licensed under the Mozilla Public License version 1.1
|
|
* with a permitted attribution clause. You may obtain a
|
|
* copy of the License at
|
|
*
|
|
* http://www.alfresco.org/legal/license.txt
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
* either express or implied. See the License for the specific
|
|
* language governing permissions and limitations under the
|
|
* License.
|
|
*/
|
|
package org.alfresco.repo.module.tool;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.util.Date;
|
|
|
|
import org.alfresco.repo.module.ModuleDetailsImpl;
|
|
|
|
import de.schlichtherle.io.File;
|
|
import de.schlichtherle.io.FileInputStream;
|
|
import de.schlichtherle.io.FileOutputStream;
|
|
|
|
/**
|
|
* Module details helper used by the module mangement tool
|
|
*
|
|
* @author Roy Wetherall
|
|
*/
|
|
public class ModuleDetailsHelper extends ModuleDetailsImpl
|
|
{
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param is input stream
|
|
*/
|
|
public ModuleDetailsHelper(InputStream is)
|
|
{
|
|
super(is);
|
|
}
|
|
|
|
/**
|
|
* Creates a module details helper object based on a file location.
|
|
*
|
|
* @param location file location
|
|
* @return module details helper object
|
|
*/
|
|
public static ModuleDetailsHelper create(String location)
|
|
{
|
|
ModuleDetailsHelper result = null;
|
|
try
|
|
{
|
|
File file = new File(location, ModuleManagementTool.defaultDetector);
|
|
if (file.exists() == true)
|
|
{
|
|
result = new ModuleDetailsHelper(new FileInputStream(file));
|
|
}
|
|
}
|
|
catch (IOException exception)
|
|
{
|
|
throw new ModuleManagementToolException("Unable to load module details from property file.", exception);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a module details helper object based on a war location and the module id
|
|
*
|
|
* @param warLocation the war location
|
|
* @param moduleId the module id
|
|
* @return the module details helper
|
|
*/
|
|
public static ModuleDetailsHelper create(String warLocation, String moduleId)
|
|
{
|
|
return ModuleDetailsHelper.create(ModuleDetailsHelper.getFileLocation(warLocation, moduleId));
|
|
}
|
|
|
|
/**
|
|
* Gets the file location
|
|
*
|
|
* @param warLocation the war location
|
|
* @param moduleId the module id
|
|
* @return the file location
|
|
*/
|
|
private static String getFileLocation(String warLocation, String moduleId)
|
|
{
|
|
return warLocation + ModuleManagementTool.MODULE_DIR + "/" + moduleId + "/" + "module.properties";
|
|
}
|
|
|
|
/**
|
|
* Saves the module detailsin to the war in the correct location based on the module id
|
|
*
|
|
* @param warLocation the war location
|
|
* @param moduleId the module id
|
|
*/
|
|
public void save(String warLocation, String moduleId)
|
|
{
|
|
try
|
|
{
|
|
File file = new File(getFileLocation(warLocation, moduleId), ModuleManagementTool.defaultDetector);
|
|
if (file.exists() == false)
|
|
{
|
|
file.createNewFile();
|
|
}
|
|
|
|
OutputStream os = new FileOutputStream(file);
|
|
try
|
|
{
|
|
Date now = new Date();
|
|
this.properties.setProperty(PROP_INSTALL_DATE, now.toString());
|
|
this.properties.store(os, null);
|
|
}
|
|
finally
|
|
{
|
|
os.close();
|
|
}
|
|
}
|
|
catch (IOException exception)
|
|
{
|
|
throw new ModuleManagementToolException("Unable to save module details into WAR file.", exception);
|
|
}
|
|
}
|
|
|
|
}
|