Ignore:
Timestamp:
04/18/12 15:27:13 (12 years ago)
Author:
vmipsl
Message:

BO insertion données _ insertion code medias package insertion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/web/src/com/ether/ControllerBackoffice.java

    r476 r482  
    2121 
    2222import javax.mail.MessagingException; 
     23import java.io.File; 
    2324import java.security.DigestException; 
    2425import java.security.NoSuchAlgorithmException; 
     
    462463    } 
    463464 
    464     @ControllerMethod() 
    465     public void removeJeu( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer jeuId ) 
     465    @ControllerMethod(jsonResult = true) 
     466    public JSONObject removeJeu( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer jeuId ) 
    466467            throws WebException 
    467468    { 
     
    469470        { 
    470471            getEtherService().removeJeuById( jeuId ); 
     472 
     473            final JSONObject result = new JSONObject(); 
     474            result.put( "success", "Dataset removed : " ); 
     475            return result; 
    471476        } 
    472477        catch( ServiceException e ) 
     
    482487        try 
    483488        { 
     489            final JSONObject result = new JSONObject(); 
     490 
    484491            final Jeu jeu = getEtherService().getJeuById( jeuId ); 
     492            if( null == jeu.getCategorie() || null == jeu.getCategorie().getCategorieNom() ) 
     493                throw new WebException( WebException.WebCode.JEU_NOT_CORRECT, "ERROR to move jeu to download directory to upload directory" + jeu ); 
     494 
    485495            final String downloadDirectory = (String) getServletContext().getAttribute( "accessDir" ); 
    486             final String uploadDirectory = (String) getServletContext().getAttribute( "uploadDir" ); 
    487             final boolean success = getEtherService().moveFilesFromDownloadToUpload( jeu, downloadDirectory, uploadDirectory ); 
    488  
    489             final JSONObject result = new JSONObject(); 
    490             result.put( "success", success ); 
     496            final String downloadFilesPath = downloadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
     497 
     498            if( !( new File( downloadFilesPath ) ).exists() ) 
     499                throw new WebException( WebException.WebCode.DOWNLOAD_DIRECTORY_DOESNOT_EXISTS, "The download directory doesn't exists ! No move available" + jeu, WebException.getExceptionThrowable() ); 
     500 
     501            else 
     502            { 
     503                final String uploadDirectory = (String) getServletContext().getAttribute( "uploadDir" ); 
     504                final String uploadFilesPath = uploadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
     505 
     506                final boolean success = EtherHelper.moveFiles( downloadFilesPath, uploadFilesPath ); 
     507 
     508                if( success ) 
     509                    result.put( "success", "All files moved !" ); 
     510                else 
     511                    throw new WebException( WebException.WebCode.JEU_NOT_CORRECT, "ERROR to move jeu to download directory to upload directory" + jeu ); 
     512            } 
    491513            return result; 
    492514        } 
Note: See TracChangeset for help on using the changeset viewer.