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;
|
package org.alfresco.web.bean.content;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@@ -165,14 +165,15 @@ public class CreateContentWizard extends BaseContentWizard
|
|||||||
|
|
||||||
public List<SelectItem> getCreateTemplateTypes()
|
public List<SelectItem> getCreateTemplateTypes()
|
||||||
{
|
{
|
||||||
List<TemplateType> ttl = TemplatingService.getInstance().getTemplateTypes();
|
Collection<TemplateType> ttl = TemplatingService.getInstance().getTemplateTypes();
|
||||||
List<SelectItem> sil = new ArrayList<SelectItem>(ttl.size());
|
List<SelectItem> sil = new ArrayList<SelectItem>(ttl.size());
|
||||||
Iterator it = ttl.iterator();
|
for (TemplateType tt : ttl)
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
TemplateType tt = (TemplateType)it.next();
|
|
||||||
sil.add(new SelectItem(tt.getName(), tt.getName()));
|
sil.add(new SelectItem(tt.getName(), tt.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QuickSort sorter = new QuickSort(sil, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||||
|
sorter.sort();
|
||||||
return sil;
|
return sil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,9 +17,7 @@
|
|||||||
package org.alfresco.web.templating;
|
package org.alfresco.web.templating;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.xml.parsers.*;
|
import javax.xml.parsers.*;
|
||||||
|
|
||||||
@@ -110,10 +108,18 @@ public final class TemplatingService
|
|||||||
final ObjectInputStream in = new ObjectInputStream(contentIn);
|
final ObjectInputStream in = new ObjectInputStream(contentIn);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final List<TemplateType> tt = (List<TemplateType>)in.readObject();
|
while (true)
|
||||||
for (TemplateType t : tt)
|
|
||||||
{
|
{
|
||||||
TemplatingService.INSTANCE.registerTemplateType(t);
|
try
|
||||||
|
{
|
||||||
|
final TemplateType tt = (TemplateType)in.readObject();
|
||||||
|
TemplatingService.INSTANCE.registerTemplateType(tt);
|
||||||
|
}
|
||||||
|
catch (EOFException eof)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
@@ -135,7 +141,10 @@ public final class TemplatingService
|
|||||||
if (!CONFIG_FILE.exists())
|
if (!CONFIG_FILE.exists())
|
||||||
CONFIG_FILE.createNewFile();
|
CONFIG_FILE.createNewFile();
|
||||||
final ObjectOutputStream out = new ObjectOutputStream(contentOut);
|
final ObjectOutputStream out = new ObjectOutputStream(contentOut);
|
||||||
out.writeObject(TemplatingService.INSTANCE.getTemplateTypes());
|
for (TemplateType tt : TemplatingService.INSTANCE.getTemplateTypes())
|
||||||
|
{
|
||||||
|
out.writeObject(tt);
|
||||||
|
}
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,8 +161,8 @@ public final class TemplatingService
|
|||||||
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
|
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
|
||||||
private static TemplatingService INSTANCE;
|
private static TemplatingService INSTANCE;
|
||||||
|
|
||||||
private ArrayList<TemplateType> templateTypes =
|
private HashMap<String, TemplateType> templateTypes =
|
||||||
new ArrayList<TemplateType>();
|
new HashMap<String, TemplateType>();
|
||||||
private final ContentService contentService;
|
private final ContentService contentService;
|
||||||
private final NodeService nodeService;
|
private final NodeService nodeService;
|
||||||
private final FileFolderService fileFolderService;
|
private final FileFolderService fileFolderService;
|
||||||
@@ -192,32 +201,26 @@ public final class TemplatingService
|
|||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
LOGGER.error(t);
|
LOGGER.error(t);
|
||||||
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TemplatingService.INSTANCE;
|
return TemplatingService.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TemplateType> getTemplateTypes()
|
public Collection<TemplateType> getTemplateTypes()
|
||||||
{
|
{
|
||||||
return this.templateTypes;
|
return this.templateTypes.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateType getTemplateType(final String name)
|
public TemplateType getTemplateType(final String name)
|
||||||
{
|
{
|
||||||
final Iterator it = this.templateTypes.iterator();
|
return this.templateTypes.get(name);
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final TemplateType tt = (TemplateType)it.next();
|
|
||||||
if (tt.getName().equals(name))
|
|
||||||
return tt;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerTemplateType(final TemplateType tt)
|
public void registerTemplateType(final TemplateType tt)
|
||||||
{
|
{
|
||||||
this.templateTypes.add(tt);
|
this.templateTypes.put(tt.getName(), tt);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Configuration.save();
|
Configuration.save();
|
||||||
|
@@ -197,4 +197,9 @@ public class TemplateTypeImpl
|
|||||||
{
|
{
|
||||||
return this.outputMethods;
|
return this.outputMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.getName().hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user