Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 7189 invoked from network); 24 Apr 2008 16:38:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Apr 2008 16:38:22 -0000 Received: (qmail 98849 invoked by uid 500); 24 Apr 2008 16:38:23 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 98815 invoked by uid 500); 24 Apr 2008 16:38:23 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 98803 invoked by uid 99); 24 Apr 2008 16:38:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 09:38:23 -0700 X-ASF-Spam-Status: No, hits=-1998.0 required=10.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 16:37:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8C0C51A983A; Thu, 24 Apr 2008 09:37:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r651311 - in /directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations: resources/conf/ src/main/java/org/apache/directory/studio/apacheds/experimentations/ Date: Thu, 24 Apr 2008 16:37:42 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080424163746.8C0C51A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Thu Apr 24 09:37:36 2008 New Revision: 651311 URL: http://svn.apache.org/viewvc?rev=651311&view=rev Log: Removed unused code in the Activator class. Added methods to create an instance folder with the necessary configuration files in it. Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/apacheds.conf directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/log4j.properties directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/server.xml Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginUtils.java Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/apacheds.conf URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/apacheds.conf?rev=651311&view=auto ============================================================================== --- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/apacheds.conf (added) +++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/apacheds.conf Thu Apr 24 09:37:36 2008 @@ -0,0 +1,41 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +# +# In this file you can override parameters specified in the default +# Apache Directory Server config file which is usually at +# /opt/apacheds-x.x.x/conf/apacheds.conf +# +# See also http://wrapper.tanukisoftware.org/doc/english/properties.html +# For a list of properties that can be set. +# +# Common overrides shown commented below + + +# Override the JRE used +# wrapper.java.command=%JAVA_HOME%/bin/java + +# Override the JVM memory settings +# Initial Java Heap Size (in MB) +# wrapper.java.initmemory=384 + +# Maximum Java Heap Size (in MB) +# wrapper.java.maxmemory=384 + +# apacheds.instance.start=auto \ No newline at end of file Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/log4j.properties URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/log4j.properties?rev=651311&view=auto ============================================================================== --- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/log4j.properties (added) +++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/log4j.properties Thu Apr 24 09:37:36 2008 @@ -0,0 +1,40 @@ +############################################################################# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +############################################################################# +log4j.rootCategory=WARN, R, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +log4j.appender.R=org.apache.log4j.RollingFileAppender +#log4j.appender.R.File=${apacheds.log.dir}/${apacheds.instance}/apacheds-rolling.log +log4j.appender.R.File=${apacheds.log.dir}/apacheds-rolling.log + +log4j.appender.R.MaxFileSize=1024KB +# Keep some backup files +log4j.appender.R.MaxBackupIndex=5 + +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n + +log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n + +# with these we'll not get innundated when switching to DEBUG +log4j.logger.org.apache.directory.shared.ldap.name=WARN +log4j.logger.org.springframework=WARN +log4j.logger.org.apache.directory.shared.codec=WARN +log4j.logger.org.apache.directory.shared.asn1=WARN + Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/server.xml URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/server.xml?rev=651311&view=auto ============================================================================== --- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/server.xml (added) +++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/conf/server.xml Thu Apr 24 09:37:36 2008 @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + #systemContextEntry + + + + + + + + + + + + + + + + + + + + + + + + #exampleContextEntry + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #datagramAcceptor + #socketAcceptor + + + + + #directoryService + #socketAcceptor + + + + + #directoryService + #socketAcceptor + + + SIMPLE + CRAM-MD5 + DIGEST-MD5 + + + + + + auth + auth-int + auth-conf + + + + + example.com + apache.org + + + + + + + + + + + + + + + + #directoryService + #ldapServer + #ldapsServer + + + + + newEntry + + + + objectClass: top + objectClass: organizationalUnit + objectClass: extensibleObject + ou: system + + ou=system + + + + + + + newEntry + + + + objectClass: top + objectClass: domain + objectClass: extensibleObject + dc: example + + dc=example,dc=com + + + + + + + + + + + + + + + Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java?rev=651311&r1=651310&r2=651311&view=diff ============================================================================== --- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java (original) +++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java Thu Apr 24 09:37:36 2008 @@ -26,7 +26,6 @@ import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; @@ -92,64 +91,7 @@ consoleDisplayMgr.println( "MSG_WARNING", ConsoleDisplayMgr.MSG_WARNING ); consoleDisplayMgr.println( "MSG_ERROR", ConsoleDisplayMgr.MSG_ERROR ); - IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); - for ( int i = 0; i < types.length; i++ ) - { - IVMInstallType type = types[i]; - IVMInstall[] jres = type.getVMInstalls(); - for ( IVMInstall vmInstall : jres ) - { - consoleDisplayMgr.println( vmInstall.getId(), ConsoleDisplayMgr.MSG_INFORMATION ); - consoleDisplayMgr.println( vmInstall.getName(), ConsoleDisplayMgr.MSG_INFORMATION ); - consoleDisplayMgr - .println( vmInstall.getInstallLocation().toString(), ConsoleDisplayMgr.MSG_INFORMATION ); - consoleDisplayMgr.println( vmInstall.getVMInstallType().toString(), ConsoleDisplayMgr.MSG_INFORMATION ); - consoleDisplayMgr.println( vmInstall.getVMRunner( ILaunchManager.RUN_MODE ).toString(), - ConsoleDisplayMgr.MSG_INFORMATION ); - System.out.println( vmInstall.getName() ); - } - } - - System.out.println( "*****************" ); - IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); - System.out.println( vmInstall.getId() ); - System.out.println( vmInstall.getName() ); - System.out.println( vmInstall.getInstallLocation() ); - System.out.println( vmInstall.getVMArguments() ); - System.out.println( vmInstall.getVMInstallType() ); - System.out.println( vmInstall.getVMRunner( ILaunchManager.RUN_MODE ) ); - - Thread thread = new Thread() - { - Logger LOGGER = Logger.getLogger( "testLogger" ); - - - @Override - public void run() - { - for ( int i = 0; i < 10; i++ ) - { - try - { - sleep( 2000 ); - } - catch ( InterruptedException e ) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - LOGGER.info( "INFO" ); - LOGGER.debug( "DEBUG" ); - LOGGER.warn( "WARN" ); - LOGGER.error( "ERROR" ); - LOGGER.fatal( "FATAL" ); - } - } - }; - - thread.start(); // Testing the launch configuration ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginUtils.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginUtils.java?rev=651311&r1=651310&r2=651311&view=diff ============================================================================== --- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginUtils.java (original) +++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginUtils.java Thu Apr 24 09:37:36 2008 @@ -24,6 +24,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.net.URL; import org.eclipse.core.runtime.FileLocator; @@ -41,6 +42,7 @@ { private static final String RESOURCES = "resources"; private static final String LIBS = "libs"; + private static final String INSTANCES = "instances"; /** The name of the libraries folder */ private static final String LIBRARIES_FOLDER_NAME = "libs"; private static final String APACHEDS = "apacheds"; @@ -133,12 +135,7 @@ FileOutputStream libraryOutputStream = new FileOutputStream( destination ); // Copying the library - byte[] buf = new byte[1024]; - int i = 0; - while ( ( i = libraryInputStream.read( buf ) ) != -1 ) - { - libraryOutputStream.write( buf, 0, i ); - } + copyFile( libraryInputStream, libraryOutputStream ); // Closing the streams libraryInputStream.close(); @@ -147,6 +144,27 @@ /** + * Copies a file from the given streams. + * + * @param inputStream + * the input stream + * @param outputStream + * the output stream + * @throws IOException + * if an error occurs when copying the file + */ + private static void copyFile( InputStream inputStream, OutputStream outputStream ) throws IOException + { + byte[] buf = new byte[1024]; + int i = 0; + while ( ( i = inputStream.read( buf ) ) != -1 ) + { + outputStream.write( buf, 0, i ); + } + } + + + /** * Get the path to the Apache DS libraries folder. * * @return @@ -156,5 +174,101 @@ { return Activator.getDefault().getStateLocation().append( LIBRARIES_FOLDER_NAME ).append( APACHEDS + "-" + APACHEDS_VERSION ); + } + + + /** + * Get the path to the Apache DS instances folder. + * + * @return + * the path to the Apache DS instances folder + */ + public static IPath getApacheDsInstancesFolder() + { + return Activator.getDefault().getStateLocation().append( INSTANCES ); + } + + + /** + * Creates a new instance folder for the given id. + * + * @param id + * the id of the instance + */ + public static void createNewInstanceFolder( String id ) + { + // Checking if the Apache DS instance folder exists + checkApacheDsInstancesFolder(); + + // Creating the instance folder + IPath instanceFolderPath = getApacheDsInstancesFolder().append( id ); + File instanceFolder = new File( instanceFolderPath.toOSString() ); + instanceFolder.mkdir(); + + // Creating the instance sub folders + File confFolder = new File( instanceFolder, "conf" ); + confFolder.mkdir(); + new File( instanceFolder, "ldif" ).mkdir(); + new File( instanceFolder, "log" ).mkdir(); + new File( instanceFolder, "partitions" ).mkdir(); + + // Copying default configuration files + try + { + // Copying apacheds.conf file + File apachedsConfFile = new File( confFolder, "apacheds.conf" ); + copyConfigurationFile( "apacheds.conf", apachedsConfFile ); + + // Copying log4j.properties file + File log4jPropertiesFile = new File( confFolder, "log4j.properties" ); + copyConfigurationFile( "log4j.properties", log4jPropertiesFile ); + + // Copying server.xml file + File serverXmlFile = new File( confFolder, "server.xml" ); + copyConfigurationFile( "", serverXmlFile ); + } + catch ( IOException e ) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * Copies a configuration file. + * + * @param inputFilename + * the filename + * @param ouputFile + * the output file + * @throws IOException + * if an error occurs when copying + */ + private static void copyConfigurationFile( String inputFilename, File ouputFile ) throws IOException + { + URL inputFilenameUrl = FileLocator.find( Activator.getDefault().getBundle(), new Path( RESOURCES + + IPath.SEPARATOR + "conf" + IPath.SEPARATOR + inputFilename ), null ); + InputStream inputStream = inputFilenameUrl.openStream(); + OutputStream outputStream = new FileOutputStream( ouputFile ); + + copyFile( inputStream, outputStream ); + + inputStream.close(); + outputStream.close(); + } + + + /** + * Verifies that the Apache DS instances folder exists. + * If it does not exists, it creates it. + */ + private static void checkApacheDsInstancesFolder() + { + File apacheDsInstancesFolder = new File( getApacheDsInstancesFolder().toOSString() ); + if ( !apacheDsInstancesFolder.exists() ) + { + apacheDsInstancesFolder.mkdir(); + } } }