/** * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /******************************************************************************\ * * This product was developed by * * SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), * * a government company established under Brazilian law (5.615/70), * at Department of Development of Porto Alegre. * \******************************************************************************/ package serpro.mailarchiver.view.admin; import java.io.File; import static com.eventrouter.MessagePublisher.*; import com.eventrouter.annotation.Subscribe; import com.google.common.io.Files; import org.springframework.beans.factory.annotation.Autowired; import serpro.mailarchiver.service.dto.TMessage; import serpro.mailarchiver.service.web.ArchiveServices; import serpro.mailarchiver.util.Charsets; import serpro.mailarchiver.util.Logger; import serpro.mailarchiver.view.BaseController; class UploadController extends BaseController { private static final Logger log = Logger.getLocalLogger(); UploadController(String displayId) { super(displayId); } @Override public UploadController init() { return this; } @Autowired private ArchiveServices archiveServices; @Subscribe({"/mailarchiver/tests/upload"}) public void testeUploadMessage(byte[] msgBytes, String folderId) { TMessage msgdto = null; try { String message = new String(msgBytes, Charsets.Windows_1252); msgdto = archiveServices.archive(AdminConsoleApp.getInstance().getSession().getSessionId(), folderId, message); publish("/mailarchiver/notification/humanized", "Mensagem carregada no metaarquivamento", msgdto.toString()); } catch(Exception ex) { log.error(ex); publish("/mailarchiver/notification/error", "Erro no metaarquivamento"); } } @Subscribe({"/mailarchiver/tests/upload"}) public void testeUploadMessage(File file, String filename, String folderId) { TMessage msgdto = null; try { String message = Files.toString(file, Charsets.Windows_1252); msgdto = archiveServices.archive(AdminConsoleApp.getInstance().getSession().getSessionId(), folderId, message); publish("/mailarchiver/notification/humanized", "Mensagem carregada no metaarquivamento", msgdto.toString()); } catch(Exception ex) { log.error(ex); publish("/mailarchiver/notification/error", "Erro no metaarquivamento"); } } }