Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into issue-2093-make-con…
Browse files Browse the repository at this point in the history
…tainers-support-multiple-structures
  • Loading branch information
dsilvam committed May 21, 2013
2 parents f662879 + 42e34be commit 4dd32bb
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 48 deletions.
Binary file modified bin/autoupdater/autoUpdater.jar
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion build.xml
Expand Up @@ -50,7 +50,7 @@
<property name="endorsed_libs" value="${basedir}/dotCMS/WEB-INF/endorsed_libs" />
<property name="build.autoupdater" value="${basedir}/bin/autoupdater/build" />
<property name="dist.autoupdater" value="${basedir}/bin/autoupdater" />
<property name="agent.version" value="29"/>
<property name="agent.version" value="30"/>

<property name="plugin.root.dir.default" value="${basedir}/dotCMS"/>
<property name="plugin.jar.deploy.dir.default" value="${basedir}/../../dotCMS/WEB-INF/lib" />
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/html/portlet/ext/contentlet/field/edit_field.jsp
Expand Up @@ -61,7 +61,7 @@
<style>
.dijitTree {
width: 100% !important;
max-height: 150px !important;
max-height: 100% !important;
overflow: auto;
}
</style>
Expand Down
38 changes: 28 additions & 10 deletions src/com/dotcms/autoupdater/FileUpdater.java
Expand Up @@ -49,18 +49,36 @@ public void preUpdate () throws UpdateException {
String backUpPath = home + File.separator + UpdateAgent.FOLDER_HOME_BACK_UP + File.separator + currentBackUpFolderName;
//.dotserver folder path
String dotserverPath = home + File.separator + UpdateAgent.FOLDER_HOME_DOTSERVER;
//.autoUpdater folder path
//String autoUpdaterPath = home + File.separator + UpdateAgent.FOLDER_HOME_UPDATER;

try {

/**
* Now we need to be sure we have the commons-configuration jar, it should be there, but be we better check.
* This will be need it just for old versions of the autoupdater, after 2.3.1 won't be necessary
*/
/*File updaterCommonsConfiguration = new File( autoUpdaterPath + File.separator + "libs" + File.separator + "commons-configuration-1.0.jar" );
if ( !updaterCommonsConfiguration.exists() ) {//First verify it we already have it
//Copy the one on dotCMS to the autoupdater libs folder
File commonsConfiguration = new File( dotserverPath + File.separator +
"dotCMS" + File.separator + "WEB-INF" + File.separator + "lib" + File.separator + "commons-configuration-1.0.jar" );
if ( commonsConfiguration.exists() ) {
FileUtil.copyFile( commonsConfiguration, updaterCommonsConfiguration, false );
}
}*/

//First we need to create the back up for the current project, for this we need to user hard links, this back up could be huge
FileUtil.copyDirectory(dotserverPath, backUpPath, true);
FileUtil.copyDirectory( dotserverPath, backUpPath, true );

/*//First if we don't have the ant jars, we extract them. This is a pretty ugly hack, but there's no way to guarantee the user already has them
File antLauncher = new File( home + File.separator + UpdateAgent.FOLDER_HOME_UPDATER + File.separator + "bin" + File.separator + "ant" + File.separator + "ant-launcher.jar" );
if ( !antLauncher.exists() ) {
logger.debug( Messages.getString( "UpdateAgent.debug.extracting.ant" ) );
UpdateUtil.unzipDirectory( updateFile, "bin/ant", home + File.separator + UpdateAgent.FOLDER_HOME_UPDATER, false );
}*/
} catch (Exception e) {
} catch ( Exception e ) {
String error = Messages.getString( "UpdateAgent.error.ant.prepare.back-up" );
if ( !UpdateAgent.isDebug ) {
error += Messages.getString( "UpdateAgent.text.use.verbose", UpdateAgent.logFile );
Expand Down Expand Up @@ -143,7 +161,7 @@ public boolean doUpdate () throws IOException, UpdateException {
File assetsFolder = new File( backUpPath + File.separator + assets );
File destFolder = new File( dotserverFolder + File.separator + assets );
//Copying using hardlinks
FileUtil.copyDirectory(assetsFolder, destFolder);
FileUtil.copyDirectory( assetsFolder, destFolder );
//copyFolder( assetsFolder, destFolder );

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand All @@ -155,7 +173,7 @@ public boolean doUpdate () throws IOException, UpdateException {
File esdataFolder = new File( backUpPath + File.separator + esdata );
destFolder = new File( dotserverFolder + File.separator + esdata );
//Copying using hardlinks
FileUtil.copyDirectory(esdataFolder, destFolder);
FileUtil.copyDirectory( esdataFolder, destFolder );
//copyFolder( esdataFolder, destFolder );

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand All @@ -170,7 +188,7 @@ public boolean doUpdate () throws IOException, UpdateException {
File tempDestFolder = new File( dotserverFolder + File.separator + pluginsTemp );

//First we need to move this folder to a temporal one in order to extract some files later
if (destFolder.exists()) {
if ( destFolder.exists() ) {
success = destFolder.renameTo( tempDestFolder );

if ( !success ) {
Expand All @@ -185,25 +203,25 @@ public boolean doUpdate () throws IOException, UpdateException {
//Now we need to copy the back up plugins folder
File pluginsFolder = new File( backUpPath + File.separator + plugins );
//Copying using hardlinks
FileUtil.copyDirectory(pluginsFolder, destFolder, true);
FileUtil.copyDirectory( pluginsFolder, destFolder, true );
//copyFolder( pluginsFolder, destFolder );

//Now we need to remove the common.xml and plugins.xml
File commonXML = new File( dotserverFolder + File.separator + plugins + File.separator + "common.xml" );
File pluginsXML = new File( dotserverFolder + File.separator + plugins + File.separator + "plugins.xml" );
if (commonXML.exists()) {
if ( commonXML.exists() ) {
commonXML.delete();
}
if (pluginsXML.exists()) {
if ( pluginsXML.exists() ) {
pluginsXML.delete();
}
//And copying them from the temporal plugins folder
File origCommonXML = new File( dotserverFolder + File.separator + pluginsTemp + File.separator + "common.xml" );
File origPluginsXML = new File( dotserverFolder + File.separator + pluginsTemp + File.separator + "plugins.xml" );
if (origCommonXML.exists()) {
if ( origCommonXML.exists() ) {
origCommonXML.renameTo( commonXML );
}
if (origPluginsXML.exists()) {
if ( origPluginsXML.exists() ) {
origPluginsXML.renameTo( pluginsXML );
}

Expand Down
49 changes: 24 additions & 25 deletions src/com/dotcms/autoupdater/UpdateAgent.java
Expand Up @@ -18,7 +18,7 @@
public class UpdateAgent {

public static String MANIFEST_PROPERTY_AGENT_VERSION = "Agent-Version";
private static String MANIFEST_PROPERTY_RELEASE_VERSION = "Release-Version";
//private static String MANIFEST_PROPERTY_RELEASE_VERSION = "Release-Version";

public static Logger logger;
public static boolean isDebug = false;
Expand Down Expand Up @@ -65,7 +65,6 @@ public void run ( String[] args ) {
return;
} catch ( ParseException e ) {
System.err.println( Messages.getString( "UpdateAgent.error.command.parsing" ) + e.getMessage() );

return;
}

Expand Down Expand Up @@ -108,8 +107,19 @@ public void run ( String[] args ) {
String agentVersion = UpdateUtil.getManifestValue( MANIFEST_PROPERTY_AGENT_VERSION );
logger.debug( Messages.getString( "UpdateAgent.text.autoupdater.version" ) + agentVersion );

File updateFile = null;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++VERIFY FOR NEW VERSIONS OF THE AUTOUPDATER++++++++++++++++++++
if ( !line.hasOption( UpdateOptions.NO_UPDATE ) ) {
// Check to see if new version of the updater exists
File newAgent = downloadAgent( version );
if ( newAgent != null ) {
// Exit, We found an update for the autoupdater, the auto updater script will restart the process after the update of the autoupdater.jar
logger.info( Messages.getString( "UpdateAgent.text.new.autoupdater" ) );
System.exit( 0 );
}
}

File updateFile = null;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Verify if the user specified a version to update to
Expand Down Expand Up @@ -165,18 +175,6 @@ else if ( line.hasOption( UpdateOptions.FILE ) ) {

} else {

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++VERIFY FOR NEW VERSIONS OF THE AUTOUPDATER++++++++++++++++++++
if ( !line.hasOption( UpdateOptions.NO_UPDATE ) ) {
// Check to see if new version of the updater exists
File newAgent = downloadAgent();
if ( newAgent != null ) {
// Exit, We found an update for the autoupdater, the auto updater script will restart the process after the update of the autoupdater.jar
logger.info( Messages.getString( "UpdateAgent.text.new.autoupdater" ) );
System.exit( 0 );
}
}

// Download update file
if ( minor != null ) {
logger.info( Messages.getString( "UpdateAgent.text.your.version" ) + version + " / " + minor );
Expand Down Expand Up @@ -412,7 +410,7 @@ private File findJarFile () throws IOException, UpdateException {

public boolean accept ( File pathname ) {
String fileName = pathname.getName().toLowerCase();
if ( fileName.startsWith( "dotcms_" ) && fileName.endsWith( ".jar" ) && ( !fileName.startsWith( "dotcms_ant" ) ) ) {
if ( fileName.startsWith( "dotcms_" ) && fileName.endsWith( ".jar" ) && (!fileName.startsWith( "dotcms_ant" )) ) {
return true;
}
return false;
Expand Down Expand Up @@ -477,7 +475,7 @@ private boolean checkRequisites ( String home ) throws UpdateException {
*/
private boolean checkHome ( String home ) throws UpdateException {

String[] homeCheckElements = { "build.xml", "dotCMS/WEB-INF/web.xml" };
String[] homeCheckElements = {"build.xml", "dotCMS/WEB-INF/web.xml"};

File homeFolder;
for ( String check : homeCheckElements ) {
Expand All @@ -495,7 +493,7 @@ private boolean checkHome ( String home ) throws UpdateException {
*
* @return Autoupdater client update file
*/
private File downloadAgent () {
private File downloadAgent ( String version ) {

File updateFile = new File( getHomeProjectPath() + File.separator + FOLDER_HOME_UPDATER + File.separator + "autoUpdater.new" );

Expand All @@ -504,7 +502,8 @@ private File downloadAgent () {
updateFile.createNewFile();

Map<String, String> map = new HashMap<String, String>();
map.put( "version", UpdateUtil.getManifestValue( MANIFEST_PROPERTY_RELEASE_VERSION ) );
map.put( "version", version );
//map.put( "version", UpdateUtil.getManifestValue( MANIFEST_PROPERTY_RELEASE_VERSION ) );
map.put( "agent_version", UpdateUtil.getManifestValue( MANIFEST_PROPERTY_AGENT_VERSION ) );

if ( allowTestingBuilds ) {
Expand Down Expand Up @@ -559,7 +558,7 @@ private PostMethod doGet ( String fileUrl, Map<String, String> pars ) throws IOE
Object[] keys = pars.keySet().toArray();
NameValuePair[] data = new NameValuePair[keys.length];
for ( int i = 0; i < keys.length; i++ ) {
String key = ( String ) keys[i];
String key = (String) keys[i];
NameValuePair pair = new NameValuePair( key, pars.get( key ) );
data[i] = pair;
}
Expand Down Expand Up @@ -635,13 +634,13 @@ private int download ( String downloadUrl, File outputFile, PostMethod postMetho

byte[] buffer = new byte[1024];
int bytesRead, bytesWritten = 0;
while ( ( bytesRead = is.read( buffer ) ) != -1 ) {
while ( (bytesRead = is.read( buffer )) != -1 ) {
outStream.write( buffer, 0, bytesRead );
bytesWritten += bytesRead;

//Keep tracking of the download status
long currentTime = System.currentTimeMillis();
if ( ( currentTime - startTime ) > refreshInterval ) {
if ( (currentTime - startTime) > refreshInterval ) {
String message = downloadProgress.getProgressMessage( bytesWritten, startTime, currentTime );
startTime = currentTime;
System.out.print( "\r" + message );
Expand Down Expand Up @@ -753,14 +752,14 @@ private int download ( File outputFile, PostMethod method ) throws URIException,
long startTime = System.currentTimeMillis();
long refreshInterval = 500;
DownloadProgress dp = new DownloadProgress( length );
while ( ( len = is.read( b ) ) != -1 ) {
while ( (len = is.read( b )) != -1 ) {
for ( int i = 0; i < len; i++ ) {
out.write( ( char ) b[i] );
out.write( (char) b[i] );
count++;
}
long currentTime = System.currentTimeMillis();

if ( ( currentTime - startTime ) > refreshInterval ) {
if ( (currentTime - startTime) > refreshInterval ) {
String message = dp.getProgressMessage( count, startTime, currentTime );
startTime = currentTime;
System.out.print( "\r" + message );
Expand Down
2 changes: 1 addition & 1 deletion src/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java
Expand Up @@ -134,7 +134,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
boolean trailSlash = uri.endsWith("/");
boolean isDotPage = uri.substring(uri.lastIndexOf(".")+1).equals(Config.getStringProperty("VELOCITY_PAGE_EXTENSION"));
String url = (!trailSlash && !isDotPage)?uri+'/':uri;
if (!UtilMethods.isSet(mastRegEx) || uri.contains("webdav")) {
if (!UtilMethods.isSet(mastRegEx) || uri.startsWith("/webdav")) {
chain.doFilter(req, res);
return;
}
Expand Down
Expand Up @@ -519,6 +519,7 @@ public boolean moveFolder ( String inode, String newFolder ) throws Exception {
}

refreshIndex(null, parentFolder, user, null, folder );
APILocator.getPermissionAPI().resetPermissionReferences(folder);
}
} catch ( Exception e ) {
HibernateUtil.rollbackTransaction();
Expand Down
29 changes: 20 additions & 9 deletions src/com/dotmarketing/util/Config.java
@@ -1,5 +1,9 @@
package com.dotmarketing.util;

import com.dotcms.util.AsciiArt;
import com.dotmarketing.db.DbConnectionFactory;
import org.apache.commons.configuration.PropertiesConfiguration;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
Expand All @@ -9,11 +13,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;

import org.apache.commons.configuration.PropertiesConfiguration;

import com.dotcms.util.AsciiArt;
import com.dotmarketing.db.DbConnectionFactory;

public class Config {

//Generated File Indicator
Expand Down Expand Up @@ -98,7 +97,10 @@ private static void _refreshProperties () {
*/
public static String getStringProperty(String name,String defValue) {
_refreshProperties ();
String[] propsArr = props.getStringArray(name);
if ( props == null ) {
return defValue;
}
String[] propsArr = props.getStringArray(name);
String property = new String ();
int i = 0;
if ((propsArr !=null) &&(propsArr.length>0)) {
Expand Down Expand Up @@ -149,7 +151,10 @@ public static int getIntProperty (String name) {

public static int getIntProperty (String name, int defaultVal) {
_refreshProperties ();
return props.getInt(name, defaultVal);
if ( props == null ) {
return defaultVal;
}
return props.getInt(name, defaultVal);
}
/**
* @deprecated Use getFloatProperty(String name, float default) and
Expand All @@ -163,7 +168,10 @@ public static float getFloatProperty (String name) {

public static float getFloatProperty (String name, float defaultVal) {
_refreshProperties ();
return props.getFloat(name, defaultVal);
if ( props == null ) {
return defaultVal;
}
return props.getFloat(name, defaultVal);
}
/**
* @deprecated Use getBooleanProperty(String name, boolean default) and
Expand All @@ -177,7 +185,10 @@ public static boolean getBooleanProperty (String name) {

public static boolean getBooleanProperty (String name, boolean defaultVal) {
_refreshProperties ();
return props.getBoolean(name, defaultVal);
if ( props == null ) {
return defaultVal;
}
return props.getBoolean(name, defaultVal);
}

@SuppressWarnings("unchecked")
Expand Down
2 changes: 1 addition & 1 deletion src/com/dotmarketing/util/UtilHTML.java
Expand Up @@ -460,7 +460,7 @@ public static String htmlEncode(String data)
if (chars[i] == ';')
buf.append(";");
else
buf.append("&#" + (int) chars[i]);
buf.append("&#" + (int) chars[i]+";");
}
}
return buf.toString();
Expand Down

0 comments on commit 4dd32bb

Please sign in to comment.