diff --git a/bin/autoupdater/autoUpdater.jar b/bin/autoupdater/autoUpdater.jar index 41a3df8c2159..8743498efdb7 100644 Binary files a/bin/autoupdater/autoUpdater.jar and b/bin/autoupdater/autoUpdater.jar differ diff --git a/bin/autoupdater/libs/commons-configuration-1.0.jar b/bin/autoupdater/libs/commons-configuration-1.0.jar new file mode 100644 index 000000000000..0bb8900f8ba8 Binary files /dev/null and b/bin/autoupdater/libs/commons-configuration-1.0.jar differ diff --git a/build.xml b/build.xml index 8daa6ae13505..f61d84e08ac3 100644 --- a/build.xml +++ b/build.xml @@ -50,7 +50,7 @@ - + diff --git a/dotCMS/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/html/portlet/ext/contentlet/field/edit_field.jsp index 7a1430156364..136c8a25ddfa 100644 --- a/dotCMS/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/html/portlet/ext/contentlet/field/edit_field.jsp @@ -61,7 +61,7 @@ diff --git a/src/com/dotcms/autoupdater/FileUpdater.java b/src/com/dotcms/autoupdater/FileUpdater.java index 351ec47e07ad..f06426f2467c 100644 --- a/src/com/dotcms/autoupdater/FileUpdater.java +++ b/src/com/dotcms/autoupdater/FileUpdater.java @@ -49,10 +49,28 @@ 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" ); @@ -60,7 +78,7 @@ public void preUpdate () throws UpdateException { 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 ); @@ -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 ); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -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 ); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -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 ) { @@ -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 ); } diff --git a/src/com/dotcms/autoupdater/UpdateAgent.java b/src/com/dotcms/autoupdater/UpdateAgent.java index 6ffd978895f2..c9461cbdc580 100644 --- a/src/com/dotcms/autoupdater/UpdateAgent.java +++ b/src/com/dotcms/autoupdater/UpdateAgent.java @@ -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; @@ -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; } @@ -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 @@ -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 ); @@ -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; @@ -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 ) { @@ -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" ); @@ -504,7 +502,8 @@ private File downloadAgent () { updateFile.createNewFile(); Map map = new HashMap(); - 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 ) { @@ -559,7 +558,7 @@ private PostMethod doGet ( String fileUrl, Map 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; } @@ -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 ); @@ -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 ); diff --git a/src/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java b/src/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java index baaea57c62da..0f707bd46ae3 100644 --- a/src/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java +++ b/src/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java @@ -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; } diff --git a/src/com/dotmarketing/portlets/browser/ajax/BrowserAjax.java b/src/com/dotmarketing/portlets/browser/ajax/BrowserAjax.java index 3ea04735f225..5fe562850cc5 100644 --- a/src/com/dotmarketing/portlets/browser/ajax/BrowserAjax.java +++ b/src/com/dotmarketing/portlets/browser/ajax/BrowserAjax.java @@ -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(); diff --git a/src/com/dotmarketing/util/Config.java b/src/com/dotmarketing/util/Config.java index 2b56a277cd92..2f2856dfa6ae 100644 --- a/src/com/dotmarketing/util/Config.java +++ b/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; @@ -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 @@ -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)) { @@ -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 @@ -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 @@ -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") diff --git a/src/com/dotmarketing/util/UtilHTML.java b/src/com/dotmarketing/util/UtilHTML.java index 3feef6b02de1..71d8415b5385 100644 --- a/src/com/dotmarketing/util/UtilHTML.java +++ b/src/com/dotmarketing/util/UtilHTML.java @@ -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();