Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 72297200C56 for ; Thu, 9 Mar 2017 22:15:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 70D3A160B5F; Thu, 9 Mar 2017 21:15:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 661F8160B87 for ; Thu, 9 Mar 2017 22:15:16 +0100 (CET) Received: (qmail 19168 invoked by uid 500); 9 Mar 2017 21:15:15 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 17669 invoked by uid 99); 9 Mar 2017 21:15:14 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Mar 2017 21:15:14 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 4D4873A47A9 for ; Thu, 9 Mar 2017 21:15:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1008012 [29/31] - in /websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST: ./ css/ images/ images/logos/ images/profiles/ img/ js/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/fe... Date: Thu, 09 Mar 2017 21:15:10 -0000 To: commits@felix.apache.org From: sseifert@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170309211512.4D4873A47A9@svn01-us-west.apache.org> archived-at: Thu, 09 Mar 2017 21:15:19 -0000 Added: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html ============================================================================== --- websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html (added) +++ websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html Thu Mar 9 21:15:09 2017 @@ -0,0 +1,386 @@ + + + +RemoteFileManager xref + + + +
+1   /* 
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   *   http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.felix.obrplugin;
+20  
+21  
+22  import java.io.BufferedWriter;
+23  import java.io.File;
+24  import java.io.FileWriter;
+25  import java.io.IOException;
+26  import java.io.Writer;
+27  
+28  import org.apache.maven.artifact.manager.WagonManager;
+29  import org.apache.maven.plugin.MojoExecutionException;
+30  import org.apache.maven.plugin.logging.Log;
+31  import org.apache.maven.settings.Proxy;
+32  import org.apache.maven.settings.Settings;
+33  import org.apache.maven.wagon.ConnectionException;
+34  import org.apache.maven.wagon.ResourceDoesNotExistException;
+35  import org.apache.maven.wagon.TransferFailedException;
+36  import org.apache.maven.wagon.UnsupportedProtocolException;
+37  import org.apache.maven.wagon.Wagon;
+38  import org.apache.maven.wagon.WagonException;
+39  import org.apache.maven.wagon.authentication.AuthenticationException;
+40  import org.apache.maven.wagon.authorization.AuthorizationException;
+41  import org.apache.maven.wagon.proxy.ProxyInfo;
+42  import org.apache.maven.wagon.repository.Repository;
+43  
+44  
+45  /**
+46   * this class is used to manage all connections by wagon.
+47   * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+48   */
+49  public class RemoteFileManager
+50  {
+51      /**
+52       * save the connection.
+53       */
+54      private Wagon m_wagon;
+55  
+56      /**
+57       * the wagon manager.
+58       */
+59      private WagonManager m_wagonManager;
+60  
+61      /**
+62       * the project settings.
+63       */
+64      private Settings m_settings;
+65  
+66      /**
+67       * logger instance.
+68       */
+69      private Log m_log;
+70  
+71  
+72      /**
+73       * initialize main information.
+74       * @param wm WagonManager provides by maven
+75       * @param settings settings of the current project provides by maven
+76       * @param log logger
+77       */
+78      public RemoteFileManager( WagonManager wm, Settings settings, Log log )
+79      {
+80          m_wagonManager = wm;
+81          m_settings = settings;
+82          m_log = log;
+83          m_wagon = null;
+84      }
+85  
+86  
+87      /**
+88       * disconnect the current object.
+89       */
+90      public void disconnect()
+91      {
+92          try
+93          {
+94              if ( m_wagon != null )
+95              {
+96                  m_wagon.disconnect();
+97              }
+98          }
+99          catch ( ConnectionException e )
+100         {
+101             m_log.error( "Error disconnecting Wagon", e );
+102         }
+103     }
+104 
+105 
+106     /**
+107      * connect the current object to repository given in constructor.
+108      * @param id repository id
+109      * @param url repository url
+110      * @throws MojoExecutionException
+111      */
+112     public void connect( String id, String url ) throws MojoExecutionException
+113     {
+114         Repository repository = new Repository( id, url );
+115 
+116         try
+117         {
+118             m_wagon = m_wagonManager.getWagon( repository );
+119         }
+120         catch ( UnsupportedProtocolException e )
+121         {
+122             throw new MojoExecutionException( "Unsupported protocol: '" + repository.getProtocol() + "'", e );
+123         }
+124         catch ( WagonException e )
+125         {
+126             throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
+127         }
+128 
+129         try
+130         {
+131             ProxyInfo proxyInfo = getProxyInfo( m_settings );
+132             if ( proxyInfo != null )
+133             {
+134                 m_wagon.connect( repository, m_wagonManager.getAuthenticationInfo( id ), proxyInfo );
+135             }
+136             else
+137             {
+138                 m_wagon.connect( repository, m_wagonManager.getAuthenticationInfo( id ) );
+139             }
+140         }
+141         catch ( ConnectionException e )
+142         {
+143             throw new MojoExecutionException( "Connection failed", e );
+144         }
+145         catch ( AuthenticationException e )
+146         {
+147             throw new MojoExecutionException( "Authentication failed", e );
+148         }
+149     }
+150 
+151 
+152     /**
+153      * get a file from the current repository connected.
+154      * @param url url to the targeted file
+155      * @param suffix suggested file suffix
+156      * @return get a file descriptor on the required resource
+157      * @throws MojoExecutionException
+158      */
+159     public File get( String url, String suffix ) throws MojoExecutionException
+160     {
+161         if ( m_wagon == null )
+162         {
+163             m_log.error( "must be connected first!" );
+164             return null;
+165         }
+166 
+167         File file = null;
+168         try
+169         {
+170             file = File.createTempFile( String.valueOf( System.currentTimeMillis() ), suffix );
+171         }
+172         catch ( IOException e )
+173         {
+174             throw new MojoExecutionException( "I/O problem", e );
+175         }
+176 
+177         try
+178         {
+179             m_wagon.get( url, file );
+180         }
+181         catch ( TransferFailedException e )
+182         {
+183             file.delete(); // cleanup on failure
+184             throw new MojoExecutionException( "Transfer failed", e );
+185         }
+186         catch ( AuthorizationException e )
+187         {
+188             file.delete(); // cleanup on failure
+189             throw new MojoExecutionException( "Authorization failed", e );
+190         }
+191         catch ( ResourceDoesNotExistException e )
+192         {
+193             file.delete(); // return non-existent file
+194         }
+195 
+196         return file;
+197     }
+198 
+199 
+200     /**
+201      * put a file on the current repository connected.
+202      * @param file file to upload
+203      * @param url url to copy file
+204      * @throws MojoExecutionException
+205      */
+206     public void put( File file, String url ) throws MojoExecutionException
+207     {
+208         if ( m_wagon == null )
+209         {
+210             m_log.error( "must be connected first!" );
+211             return;
+212         }
+213 
+214         try
+215         {
+216             m_wagon.put( file, url );
+217         }
+218         catch ( TransferFailedException e )
+219         {
+220             throw new MojoExecutionException( "Transfer failed", e );
+221         }
+222         catch ( AuthorizationException e )
+223         {
+224             throw new MojoExecutionException( "Authorization failed", e );
+225         }
+226         catch ( ResourceDoesNotExistException e )
+227         {
+228             throw new MojoExecutionException( "Resource does not exist:" + file, e );
+229         }
+230     }
+231 
+232 
+233     /**
+234      * Convenience method to map a Proxy object from the user system settings to a ProxyInfo object.
+235      * @param settings project settings given by maven
+236      * @return a proxyInfo object instancied or null if no active proxy is define in the settings.xml
+237      */
+238     public static ProxyInfo getProxyInfo( Settings settings )
+239     {
+240         ProxyInfo proxyInfo = null;
+241         if ( settings != null && settings.getActiveProxy() != null )
+242         {
+243             Proxy settingsProxy = settings.getActiveProxy();
+244 
+245             proxyInfo = new ProxyInfo();
+246             proxyInfo.setHost( settingsProxy.getHost() );
+247             proxyInfo.setType( settingsProxy.getProtocol() );
+248             proxyInfo.setPort( settingsProxy.getPort() );
+249             proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() );
+250             proxyInfo.setUserName( settingsProxy.getUsername() );
+251             proxyInfo.setPassword( settingsProxy.getPassword() );
+252         }
+253 
+254         return proxyInfo;
+255     }
+256 
+257 
+258     public void lockFile( String fileName, boolean ignoreLock ) throws MojoExecutionException
+259     {
+260         if ( !ignoreLock )
+261         {
+262             int countError = 0;
+263             while ( isLockedFile( fileName ) && countError < 2 )
+264             {
+265                 countError++;
+266                 m_log.warn( "File is currently locked, retry in 10s" );
+267                 try
+268                 {
+269                     Thread.sleep( 10000 );
+270                 }
+271                 catch ( InterruptedException e )
+272                 {
+273                     m_log.warn( "Sleep interrupted" );
+274                 }
+275             }
+276 
+277             if ( countError == 2 )
+278             {
+279                 m_log.error( "File " + fileName + " is locked. Use -DignoreLock to force uploading" );
+280                 throw new MojoExecutionException( "Remote file locked" );
+281             }
+282         }
+283 
+284         File file = null;
+285         try
+286         {
+287             // create a non-empty file used to lock the remote file
+288             file = File.createTempFile( String.valueOf( System.currentTimeMillis() ), ".lock" );
+289 
+290             Writer writer = new BufferedWriter( new FileWriter( file ) );
+291             writer.write( "LOCKED" );
+292             writer.close();
+293 
+294             put( file, fileName + ".lock" );
+295         }
+296         catch ( IOException e )
+297         {
+298             throw new MojoExecutionException( "I/O problem", e );
+299         }
+300         finally
+301         {
+302             if ( null != file )
+303             {
+304                 file.delete();
+305             }
+306         }
+307     }
+308 
+309 
+310     public void unlockFile( String fileName ) throws MojoExecutionException
+311     {
+312         File file = null;
+313         try
+314         {
+315             // clear the contents of the file used to lock the remote file
+316             file = File.createTempFile( String.valueOf( System.currentTimeMillis() ), ".lock" );
+317 
+318             Writer writer = new BufferedWriter( new FileWriter( file ) );
+319             writer.write( " " ); // write 1 byte to force wagon upload
+320             writer.close();
+321 
+322             put( file, fileName + ".lock" );
+323         }
+324         catch ( IOException e )
+325         {
+326             throw new MojoExecutionException( "I/O problem", e );
+327         }
+328         finally
+329         {
+330             if ( null != file )
+331             {
+332                 file.delete();
+333             }
+334         }
+335     }
+336 
+337 
+338     /**
+339      * this method indicates if the targeted file is locked or not.
+340      * @param fileName name targeted
+341      * @return  true if the required file is locked, else false
+342      * @throws MojoExecutionException
+343      */
+344     public boolean isLockedFile( String fileName ) throws MojoExecutionException
+345     {
+346         File file = null;
+347         try
+348         {
+349             file = get( fileName + ".lock", ".lock" );
+350 
+351             // file is locked with contents "LOCKED"
+352             if ( null != file && file.length() <= 2 )
+353             {
+354                 return false;
+355             }
+356         }
+357         finally
+358         {
+359             if ( null != file )
+360             {
+361                 file.delete();
+362             }
+363         }
+364 
+365         return true;
+366     }
+367 
+368 
+369     public String toString()
+370     {
+371         return m_wagon.getRepository().getUrl();
+372     }
+373 }
+
+
+ + + \ No newline at end of file Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Thu Mar 9 21:15:09 2017 @@ -0,0 +1 @@ +LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/RemoteFileManager.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html ============================================================================== --- websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html (added) +++ websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html Thu Mar 9 21:15:09 2017 @@ -0,0 +1,123 @@ + + + +XmlHelper xref + + + +
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   *   http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.felix.obrplugin;
+20  
+21  
+22  import org.w3c.dom.Node;
+23  import org.w3c.dom.NodeList;
+24  
+25  
+26  /**
+27   * Provide XML helper methods to support pre-Java5 runtimes
+28   * 
+29   * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+30   */
+31  public class XmlHelper
+32  {
+33      /**
+34       * based on public Java5 javadoc of org.w3c.dom.Node.getTextContent method
+35       */
+36      public static String getTextContent( Node node )
+37      {
+38          switch ( node.getNodeType() )
+39          {
+40              case Node.ELEMENT_NODE:
+41              case Node.ATTRIBUTE_NODE:
+42              case Node.ENTITY_NODE:
+43              case Node.ENTITY_REFERENCE_NODE:
+44              case Node.DOCUMENT_FRAGMENT_NODE:
+45                  return mergeTextContent( node.getChildNodes() );
+46              case Node.TEXT_NODE:
+47              case Node.CDATA_SECTION_NODE:
+48              case Node.COMMENT_NODE:
+49              case Node.PROCESSING_INSTRUCTION_NODE:
+50                  return node.getNodeValue();
+51              case Node.DOCUMENT_NODE:
+52              case Node.DOCUMENT_TYPE_NODE:
+53              case Node.NOTATION_NODE:
+54              default:
+55                  return null;
+56          }
+57      }
+58  
+59  
+60      /**
+61       * based on the following quote from public Java5 javadoc of org.w3c.dom.Node.getTextContent method:
+62       * 
+63       * "concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and
+64       * PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children"
+65       */
+66      private static String mergeTextContent( NodeList nodes )
+67      {
+68          StringBuffer buf = new StringBuffer();
+69          for ( int i = 0; i < nodes.getLength(); i++ )
+70          {
+71              Node n = nodes.item( i );
+72              final String text;
+73  
+74              switch ( n.getNodeType() )
+75              {
+76                  case Node.COMMENT_NODE:
+77                  case Node.PROCESSING_INSTRUCTION_NODE:
+78                      text = null;
+79                      break;
+80                  default:
+81                      text = getTextContent( n );
+82                      break;
+83              }
+84  
+85              if ( text != null )
+86              {
+87                  buf.append( text );
+88              }
+89          }
+90          return buf.toString();
+91      }
+92  
+93  
+94      /**
+95       * based on public Java5 javadoc of org.w3c.dom.Node.setTextContent method
+96       */
+97      public static void setTextContent( Node node, final String text )
+98      {
+99          while ( node.hasChildNodes() )
+100         {
+101             node.removeChild( node.getFirstChild() );
+102         }
+103 
+104         if ( text != null && text.length() > 0 )
+105         {
+106             Node textNode = node.getOwnerDocument().createTextNode( text );
+107             node.appendChild( textNode );
+108         }
+109     }
+110 }
+
+
+ + + \ No newline at end of file Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Thu Mar 9 21:15:09 2017 @@ -0,0 +1 @@ +LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/XmlHelper.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html ============================================================================== --- websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html (added) +++ websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html Thu Mar 9 21:15:09 2017 @@ -0,0 +1,63 @@ + + + + + + Maven Bundle Plugin 3.3.0 Reference Package org.apache.felix.obrplugin + + + + +

+ org.apache.felix.obrplugin +

+ +

Classes

+ + + + + \ No newline at end of file Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Thu Mar 9 21:15:09 2017 @@ -0,0 +1 @@ +LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-frame.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html ============================================================================== --- websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html (added) +++ websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html Thu Mar 9 21:15:09 2017 @@ -0,0 +1,134 @@ + + + + + + Maven Bundle Plugin 3.3.0 Reference Package org.apache.felix.obrplugin + + + +
+ +
+
+ +
+ +

Package org.apache.felix.obrplugin

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class Summary
+ AbstractFileMojo +
+ Config +
+ ObrCleanRepo +
+ ObrDeploy +
+ ObrDeployFile +
+ ObrIndex +
+ ObrInstall +
+ ObrInstallFile +
+ ObrRemoteClean +
+ ObrUpdate +
+ ObrUtils +
+ PomHelper +
+ RemoteFileManager +
+ XmlHelper +
+ +
+ +
+
+ +
+
+ + + \ No newline at end of file Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Thu Mar 9 21:15:09 2017 @@ -0,0 +1 @@ +LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author Propchange: websites/production/felix/content/components/bundle-plugin-archives/bundle-plugin-LATEST/xref/org/apache/felix/obrplugin/package-summary.html ------------------------------------------------------------------------------ svn:mime-type = text/plain