mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
reduce dangers of creating the same xml content type by remove the possibility of multiple xml content types with the same name. sort content types alphabetically in the dropdown. refine reading of templating configuration.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3601 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
@@ -165,14 +165,15 @@ public class CreateContentWizard extends BaseContentWizard
|
||||
|
||||
public List<SelectItem> getCreateTemplateTypes()
|
||||
{
|
||||
List<TemplateType> ttl = TemplatingService.getInstance().getTemplateTypes();
|
||||
Collection<TemplateType> ttl = TemplatingService.getInstance().getTemplateTypes();
|
||||
List<SelectItem> sil = new ArrayList<SelectItem>(ttl.size());
|
||||
Iterator it = ttl.iterator();
|
||||
while (it.hasNext())
|
||||
for (TemplateType tt : ttl)
|
||||
{
|
||||
TemplateType tt = (TemplateType)it.next();
|
||||
sil.add(new SelectItem(tt.getName(), tt.getName()));
|
||||
}
|
||||
|
||||
QuickSort sorter = new QuickSort(sil, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
return sil;
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,7 @@
|
||||
package org.alfresco.web.templating;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.xml.parsers.*;
|
||||
|
||||
@@ -110,10 +108,18 @@ public final class TemplatingService
|
||||
final ObjectInputStream in = new ObjectInputStream(contentIn);
|
||||
try
|
||||
{
|
||||
final List<TemplateType> tt = (List<TemplateType>)in.readObject();
|
||||
for (TemplateType t : tt)
|
||||
while (true)
|
||||
{
|
||||
TemplatingService.INSTANCE.registerTemplateType(t);
|
||||
try
|
||||
{
|
||||
final TemplateType tt = (TemplateType)in.readObject();
|
||||
TemplatingService.INSTANCE.registerTemplateType(tt);
|
||||
}
|
||||
catch (EOFException eof)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
@@ -135,7 +141,10 @@ public final class TemplatingService
|
||||
if (!CONFIG_FILE.exists())
|
||||
CONFIG_FILE.createNewFile();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(contentOut);
|
||||
out.writeObject(TemplatingService.INSTANCE.getTemplateTypes());
|
||||
for (TemplateType tt : TemplatingService.INSTANCE.getTemplateTypes())
|
||||
{
|
||||
out.writeObject(tt);
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
@@ -152,8 +161,8 @@ public final class TemplatingService
|
||||
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
|
||||
private static TemplatingService INSTANCE;
|
||||
|
||||
private ArrayList<TemplateType> templateTypes =
|
||||
new ArrayList<TemplateType>();
|
||||
private HashMap<String, TemplateType> templateTypes =
|
||||
new HashMap<String, TemplateType>();
|
||||
private final ContentService contentService;
|
||||
private final NodeService nodeService;
|
||||
private final FileFolderService fileFolderService;
|
||||
@@ -192,32 +201,26 @@ public final class TemplatingService
|
||||
catch (Throwable t)
|
||||
{
|
||||
LOGGER.error(t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return TemplatingService.INSTANCE;
|
||||
}
|
||||
|
||||
public List<TemplateType> getTemplateTypes()
|
||||
public Collection<TemplateType> getTemplateTypes()
|
||||
{
|
||||
return this.templateTypes;
|
||||
return this.templateTypes.values();
|
||||
}
|
||||
|
||||
public TemplateType getTemplateType(final String name)
|
||||
{
|
||||
final Iterator it = this.templateTypes.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final TemplateType tt = (TemplateType)it.next();
|
||||
if (tt.getName().equals(name))
|
||||
return tt;
|
||||
}
|
||||
return null;
|
||||
return this.templateTypes.get(name);
|
||||
}
|
||||
|
||||
public void registerTemplateType(final TemplateType tt)
|
||||
{
|
||||
this.templateTypes.add(tt);
|
||||
this.templateTypes.put(tt.getName(), tt);
|
||||
try
|
||||
{
|
||||
Configuration.save();
|
||||
|
@@ -197,4 +197,9 @@ public class TemplateTypeImpl
|
||||
{
|
||||
return this.outputMethods;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user