Package org.gudy.azureus2.plugins.platform

Examples of org.gudy.azureus2.plugins.platform.PlatformManagerException


     
    File  bundle_file = getAbsoluteBundleFile();
     
      if ( !bundle_file.exists()){
       
       throw( new PlatformManagerException( "Failed to write set run-at-login, bundle not found" ));
      }
     
      File f = getLoginPList();
     
      if ( f.exists()){
       
        convertToXML( f );
       
      }else{
       
        try{
          PrintWriter pw = new PrintWriter( new OutputStreamWriter( new FileOutputStream( f ), "UTF-8" ));
         
          try{
         
            pw.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
            pw.println( "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" );
            pw.println( "<plist version=\"1.0\">" );
            pw.println( "<dict>" );
           
            pw.println( "</dict>" );
            pw.println( "</plist>" );

          }finally{
           
            pw.close();
          }
        }catch( Throwable e ){
         
          throw( new PlatformManagerException( "Failed to write output file", e ));
        }
      }
     
 
      try{
        List<String>  lines = new ArrayList<String>();
       
        LineNumberReader lnr = new LineNumberReader( new InputStreamReader(new FileInputStream( f ), "UTF-8" ));
       
        int  dict_line       = -1;
        int  auto_launch_line   = -1;
        int  target_index    = -1;
       
        String  target = bundle_file.getAbsolutePath();
       
        try{
          while( true ){
           
            String line = lnr.readLine();
           
            if ( line == null ){
             
              break;
            }
         
           lines.add( line );
           
            if ( dict_line == -1 && containsTag( line, "<dict>" )){
             
              dict_line = lines.size();
            }
           
            if ( auto_launch_line == -1 && containsTag( line, "AutoLaunchedApplicationDictionary" )){
             
              auto_launch_line = lines.size();
            }
           
            if ( line.contains( target )){
             
              target_index = lines.size();
            }
          }
           
          if ( dict_line == -1 ){
           
            throw( new PlatformManagerException( "Malformed plist - no 'dict' entry" ));
          }
         
          if ( auto_launch_line == -1 ){
           
            lines.add( dict_line, "\t<key>AutoLaunchedApplicationDictionary</key>" );
           
            auto_launch_line = dict_line+1;
           
            lines.add( auto_launch_line, "\t<array>" );
            lines.add( auto_launch_line+1, "\t</array>" );
          }
        }finally{
         
          lnr.close();
        }
       
        if ( run ){
         
          if ( target_index != -1 || auto_launch_line == -1 ){
           
            return;
          }
         
          target_index = auto_launch_line+1;
         
         lines.add( target_index++, "\t\t<dict>" );
        lines.add( target_index++, "\t\t\t<key>Path</key>" );
        lines.add( target_index++, "\t\t\t<string>" + target + "</string>" );
         lines.add( target_index++, "\t\t</dict>" );
         
        }else{
         
          if ( target_index == -1 ){
           
            return;
          }
         
          while( !containsTag( lines.get( target_index ), "</dict>" )){
           
            lines.remove( target_index );
          }
         
          lines.remove( target_index );
         
          target_index--;
         
          while( !containsTag( lines.get( target_index ), "<dict>" )){
           
            lines.remove( target_index );
           
            target_index--;
          }
         
          lines.remove( target_index );
        }
       
        File  backup = new File( f.getParentFile(), f.getName() + ".bak" );
       
        if ( backup.exists()){
         
          backup.delete();
        }
       
        if ( !f.renameTo( backup )){
         
          throw( new PlatformManagerException( "Failed to backup " + f ));
        }
       
      boolean  ok = false;
     
      try{
        PrintWriter pw = new PrintWriter( new OutputStreamWriter( new FileOutputStream( f ), "UTF-8" ));
       
        try{
       
          for ( String line: lines ){
           
            pw.println( line );
          }
        }finally{
         
          pw.close();
         
          if ( pw.checkError()){
           
            throw( new PlatformManagerException( "Failed to write output file" ));
          }
         
          ok = true;
        }
      }finally{
       
        if ( !ok ){
         
          backup.renameTo( f );
        }
      }
  
      }catch( PlatformManagerException e ){
       
        throw( e );
       
      }catch( Throwable e ){
       
        throw( new PlatformManagerException( "Failed to write output file", e ));
      }
     }
View Full Code Here


         
          lnr.close();
        }
      }catch( Throwable e ){
       
        throw( new PlatformManagerException( "Failed to convert plist to xml" ));
      }
    }
View Full Code Here

      if( !osx_app_bundle.exists() ) {
        String msg = "OSX app bundle not found: [" +osx_app_bundle.toString()+ "]";
        System.out.println( msg );
        if (Logger.isEnabled())
          Logger.log(new LogEvent(LOGID, msg));   
        throw new PlatformManagerException( msg );
      }
     
      return "open -a \"" +osx_app_bundle.toString()+ "\"";
      //return osx_app_bundle.toString() +"/Contents/MacOS/JavaApplicationStub";
     
View Full Code Here

    String    name,        // e.g. "BitTorrent"
    String    type )        // e.g. ".torrent"
 
    throws PlatformManagerException
  {
      throw new PlatformManagerException("Unsupported capability called on platform manager");
  }
View Full Code Here

    String    name,        // e.g. "BitTorrent"
    String    type )        // e.g. ".torrent"
   
    throws PlatformManagerException
  {
    throw new PlatformManagerException("Unsupported capability called on platform manager");
  }
View Full Code Here

    String    type,        // e.g. ".torrent"
    String    content_type )    // e.g. "application/x-bittorrent"
 
    throws PlatformManagerException
  {
     throw new PlatformManagerException("Unsupported capability called on platform manager");
  }
View Full Code Here

        {
            performRuntimeExec(cmd.split(" "));
        }
        catch (Throwable e)
        {
            throw new PlatformManagerException("Failed to create process", e);
        }
    }
View Full Code Here

                performOSAScript(sb);
            }
            catch (Throwable e)
            {
                throw new PlatformManagerException("Failed to move file", e);
            }
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void setTCPTOSEnabled(boolean enabled) throws PlatformManagerException
    {
        throw new PlatformManagerException("Unsupported capability called on platform manager");
    }
View Full Code Here

    String  from_file_name,
    String  to_file_name )
 
    throws PlatformManagerException
  {
      throw new PlatformManagerException("Unsupported capability called on platform manager");   
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.platform.PlatformManagerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.