Files
alfresco-community-repo/source/java/org/alfresco/web/bean/trashcan/TrashcanRecoverItemDialog.java
Dave Ward 95454a34dc Merged V4.1-BUG-FIX to HEAD
39199: Fixed ALF-13252 "Share - Added aspects are not shown in folder properties"
   39235: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_07_09 to BRANCHES/DEV/V4.1-BUG-FIX:
      38994: ALF-14983 : Upgrade scripts to increase column sizes for Activiti
      39052: ALF-14983 : Upgrade scripts to increase column sizes for Activiti
      (note: reviewed and merged, including required merge ghanges to .sql, .properties, .xml for schema number update 5111 -> 5112)
   39239: ALF-14111 CLONE - 60k sites: Groups are not displayed in all supported browsers when 60k sites and 60 groups in the system
      - Code works on 3.4 as it includes a fix for ALF-7604 (3.4.2).
      - V4.1 should also have this fix (but did not) as there was a clone ALF-7734 (of ALF-7604) applied to Team that
        was merged to HEAD (and hence 4.x). The merge to HEAD failed to include this fix.
      - Putting this code back into 4.1.1 - this should correct this issue (ALF-14111) as the code will no longer have to sort
        240,000 groups when there are 60,000 user created groups. 
   39257: ALF-10730: Fall back on parentType for icons if necessary
   39307: Fix for ALF-14799 - jsonUtils.toJSONString() outputs long values as floating-point numbers
    - Updated to latest Surf libs rev 1101 which fixes this issue
   39310: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_07_09 to BRANCHES/DEV/V4.1-BUG-FIX
      39071: ALF-13767: User error messages in org.alfresco.repo.web.scripts are all hardcoded and cannot be localised
             Modify Java backed webscripts to return localised messages to model.
   39345: Impl from Shane Frensley to fix ALF-3484 - Alfresco should show meaningful error message when deleted item recovery fails.
   39362: RECORD ONLY MERGE from V3.4-BUG-FIX to V4.1-BUG-FIX
      39360: <<DO NOT MERGE TO V4.1-BUG-FIX>>
      Remove the creation of OSX installers - we will never need them any more since they are neither distributed not trialled
   39416: Fix for ALF-14466 Share Document Library breaks for obscure control character in document title
   39594: Minor formatting tweak for coding standards consistency.
   39622: ALF-9254: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1)
      39605: ALF-15227 3.4 CLONE - Alfresco incapable of previewing text files including non Western European characters without custom configuration 
         - transformer.PdfBox.TextToPdf no longer does txt to pdf transform as OOo/JOD handles non western chars better and are not that
           much slower even for western encodings
           - It still does csv and xml to pdf
           - transformer.complex.Text.Pdf2swf now has a wild card first transformer for text to pdf (rather than transformer.PdfBox.TextToPdf)
             The 2nd transform is still transformer.Pdf2swf. As a result transformer.PdfBox.TextToPdf or the OOo/JOD transformers may be used.
           - transformer.complex.Archive.Pdf2swf now has a wild card first transformer for the same reason.
           - transformer.complex.Text.Image now has a wild card first transformer for the same reason.
         - Allow transformer config element supportedTransformations to wild card source or target mimetype
   39692: ALF-9254: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1)
      39679: ALF-15227 3.4 CLONE - Alfresco incapable of previewing text files including non Western European characters without custom configuration 
         - Fix build failures (not sure about RecordsManagementAuditServiceImplTest)
         - Reset some of the text to pdf / swf limits now OOo or JOD is used rather than PDFBox
   39719: ALF-13037: Ensure that doclist is refreshed when on edit properties triggered folder rule that causes documents to be moved
   39734: Improvements to reduce need to index Surf component XML files - parent config folders already dealt with, but this removes the burden of indexing the XML content. (ALF-10826)
   39740: Merged BRANCHES/V4.1 to BRANCHES/DEV/V4.1-BUG-FIX: (record-only - already present)
      39734: Improvements to reduce need to index Surf component XML files - parent config folders already dealt with, but this removes the burden of indexing the XML content.
   39779: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY)
      39774: ALF-15262: Merged V4.0-BUG-FIX to V3.4-BUG-FIX
         35738: Merged HEAD to BRANCHES/DEV/V4.0-BUG-FIX:
            35737: Fix for ALF-11923. Linked rules can't be deleted if source folder was deleted.
         35751: Addendum to fix for ALF-11923. Fixing failing test case by tightening up delete behaviour.
            I also fixed the @since annotations from Odin to 3.4.11
      39777: ALF-15262: Fixed compilation error by re-introducing typo in method name!
   39784: Merged BRANCHES/V4.1 to BRANCHES/DEV/V4.1-BUG-FIX (RECORD ONLY)
      39775: ALF-15271: "Site Content" dashlet shows all documents from all the sites in Alfresco Share
   39831: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (4.1.1)
      39015: Merged in upgrade of truezip to 7.5.5 see ALF-14247
      39361: Added truezip-swing jar.  It seems that Truezip needs Swing :(


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@40265 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-08-09 16:37:33 +00:00

169 lines
6.7 KiB
Java

/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.web.bean.trashcan;
import java.text.MessageFormat;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.alfresco.repo.node.archive.RestoreNodeReport;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.ui.common.ReportedException;
public class TrashcanRecoverItemDialog extends TrashcanDialog
{
private static final long serialVersionUID = -8237457079397611071L;
private static final String RICHLIST_ID = "trashcan-list";
private static final String RICHLIST_MSG_ID = "trashcan" + ':' + RICHLIST_ID;
private static final String MSG_RECOVERED_ITEM_SUCCESS = "recovered_item_success";
private static final String MSG_RECOVERED_ITEM_DUPLICATE = "recovered_item_duplicate";
private static final String MSG_RECOVERED_ITEM_INTEGRITY = "recovered_item_integrity";
private static final String MSG_RECOVERED_ITEM_PERMISSION = "recovered_item_permission";
private static final String MSG_RECOVERED_ITEM_PARENT = "recovered_item_parent";
private static final String MSG_RECOVERED_ITEM_FAILURE = "recovered_item_failure";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private static final String MSG_RECOVER_ITEM = "recover_item";
private static final String MSG_NO = "no";
private static final String MSG_YES = "yes";
private String recoverItem(FacesContext context, String outcome)
{
Node item = property.getItem();
if (item != null)
{
FacesContext fc = context;
try
{
String msg;
FacesMessage errorfacesMsg = null;
// restore the node - the user may have requested a restore to a
// different parent
RestoreNodeReport report;
if (property.getDestination() == null)
{
report = property.getNodeArchiveService().restoreArchivedNode(item.getNodeRef());
}
else
{
report = property.getNodeArchiveService().restoreArchivedNode(item.getNodeRef(), property.getDestination(), null, null);
}
switch (report.getStatus())
{
case SUCCESS:
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_SUCCESS), item.getName());
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
fc.addMessage(RICHLIST_MSG_ID, facesMsg);
break;
case FAILURE_INVALID_PARENT:
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_PARENT), item.getName());
errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
break;
case FAILURE_PERMISSION:
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_PERMISSION), item.getName());
errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
break;
case FAILURE_INTEGRITY:
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_INTEGRITY), item.getName());
errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
break;
case FAILURE_DUPLICATE_CHILD_NODE_NAME:
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_DUPLICATE), item.getName());
errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
break;
default:
String reason = report.getCause().getMessage();
msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_FAILURE), item.getName(), reason);
errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
break;
}
// report the failure if one occured we stay on the current
// screen
if (errorfacesMsg != null)
{
fc.addMessage(null, errorfacesMsg);
}
}
catch (Throwable err)
{
// most exceptions will be caught and returned as
// RestoreNodeReport objects by the service
String reason = err.getMessage();
String msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_FAILURE), item.getName(), reason);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
fc.addMessage(null, facesMsg);
ReportedException.throwIfNecessary(err);
}
}
return outcome;
}
@Override
protected String getDefaultFinishOutcome()
{
return "dialog:close[2]";
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return recoverItem(context, outcome);
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_RECOVER_ITEM) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ property.getItem().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_NO);
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_YES);
}
}