Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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.
  */
 package org.apache.felix.webconsole.internal.obr;
 
 
 import java.net.URL;
 
 
 import  org.osgi.service.log.LogService;
 import  org.osgi.service.obr.Repository;
 import  org.osgi.service.obr.RepositoryAdmin;
 
 
 public class RefreshRepoAction extends AbstractObrPlugin implements Action
 {
 
     public static final String NAME = "refreshOBR";
 
     public static final String PARAM_REPO = "repository";
 
 
     public String getName()
     {
         return ;
     }
 
 
     public String getLabel()
     {
         return ;
     }
 
 
     public boolean performActionHttpServletRequest requestHttpServletResponse response )
     {
 
         RepositoryAdmin repoAdmin = getRepositoryAdmin();
         if ( repoAdmin != null )
         {
             String repositoryURL = request.getParameter"repository" );
             Repository[] repos = repoAdmin.listRepositories();
             Repository repo = this.getRepositoryreposrepositoryURL );
 
             URL repoURL = null;
             if ( repo != null )
             {
                 repoURL = repo.getURL();
             }
             else
             {
                 try
                 {
                     repoURL = new URLrepositoryURL );
                 }
                 catch ( Throwable t )
                 {
                     getLog().log( LogService.LOG_ERROR,
                         "RefreshRepoAction: Submitted URL " + repositoryURL + " is invalid: " + t.getMessage() );
                 }
             }
 
             // log.log(LogService.LOG_DEBUG, "Refreshing " + repo.getURL());
             if ( repoURL != null )
             {
                 if ( request.getParameter"remove" ) != null )
                 {
                     try
                     {
                         repoAdmin.removeRepository( repoURL );
                         getLog().log( LogService.LOG_INFO, "RefreshRepoAction: Removed repository " + repositoryURL );
                     }
                     catch ( Exception e )
                     {
                          getLog().log( LogService.LOG_ERROR,
                             "RefreshRepoAction: Failed removing repository " + repositoryURLe );
                     }
                 }
                 else
                 {
                     try
                     {
                         repoAdmin.addRepository( repoURL );
                        getLog().log( LogService.LOG_INFO, "RefreshRepoAction: Added repository " + repositoryURL );
                    }
                    catch ( Exception e )
                    {
                        getLog().log( LogService.LOG_ERROR,
                            "RefreshRepoAction: Failed adding repository " + repositoryURLe );
                    }
                }
            }
        }
        return true;
    }
    // ---------- internal -----------------------------------------------------
    private Repository getRepository( Repository[] reposString repositoryUrl )
    {
        if ( repositoryUrl == null || repositoryUrl.length() == 0 )
        {
            return null;
        }
        for ( int i = 0; i < repos.length; i++ )
        {
            if ( repositoryUrl.equalsrepos[i].getURL().toString() ) )
            {
                return repos[i];
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X