use of java.util.MissingResourceException in project processdash by dtuma.
the class WBSModelMergeConflictNotificationFactory method refineAttributeNotification.
private static boolean refineAttributeNotification(MergeConflictNotification mcn, DataModelSource dms) {
if (!(mcn.getMergeWarning() instanceof AttributeMergeWarning))
return false;
ModelType modelType = mcn.getModelType();
AttributeMergeWarning amw = (AttributeMergeWarning) mcn.getMergeWarning();
DataTableModel dataModel = dms.getDataModel(modelType);
ConflictCapableDataColumn column = findColumnForAttribute(dataModel, amw.getAttributeName());
if (column == null)
return false;
String columnId = column.getColumnID().replace(' ', '_');
mcn.putAttribute(COLUMN_ID, columnId);
mcn.putAttribute(COLUMN_NAME, column.getColumnName());
String explicitMessageKey = modelType.name() + ".Attribute." + columnId;
String nullDisplay;
try {
nullDisplay = resources.getHTML(explicitMessageKey + ".Blank");
} catch (MissingResourceException mre) {
nullDisplay = resources.getHTML("WBSNode_Attribute.Blank");
}
WBSNode baseNode = mcn.getAttribute(MergeConflictNotification.BASE_NODE);
String baseValue = (String) amw.getBaseValue();
Object baseDisp = (//
baseNode == null ? //
baseValue : column.getConflictDisplayValue(baseValue, baseNode));
if (baseDisp == null)
baseDisp = nullDisplay;
WBSNode mainNode = mcn.getAttribute(MergeConflictNotification.MAIN_NODE);
String mainValue = (String) amw.getMainValue();
Object mainDisp = (//
mainNode == null ? //
mainValue : column.getConflictDisplayValue(mainValue, mainNode));
if (mainDisp == null)
mainDisp = nullDisplay;
WBSNode incNode = mcn.getAttribute(MergeConflictNotification.INCOMING_NODE);
String incValue = (String) amw.getIncomingValue();
Object incDisp = (//
incNode == null ? //
incValue : column.getConflictDisplayValue(incValue, incNode));
if (incDisp == null)
incDisp = nullDisplay;
mcn.putValueAttributes(baseDisp, mainDisp, incDisp);
boolean supportsOverride;
if (MergeConflictNotification.definesDescription(explicitMessageKey)) {
// this column has explicitly defined a message it wants to
// display, so we will use that message.
mcn.setMessageKey(explicitMessageKey);
// see if this column has defined a message for the
// 'override' option.
supportsOverride = mcn.definesMessageForUserOption(MergeConflictNotification.OVERRIDE);
} else {
// use a generic message.
mcn.setMessageKey("WBSNode_Attribute");
supportsOverride = true;
}
// Add "accept" as an option that is always present
mcn.addUserOption(MergeConflictNotification.ACCEPT, null);
// Add an "alter" option if it is supported
if (supportsOverride)
mcn.addUserOption(MergeConflictNotification.OVERRIDE, new WbsNodeAttributeHandler(dataModel, column));
// give the column a final chance to tweak the configuration
column.adjustConflictNotification(mcn);
return true;
}
use of java.util.MissingResourceException in project processdash by dtuma.
the class OpenDocument method getProp.
private String getProp(Element e, String resName, String defValue) {
if (e == null)
return defValue;
Document doc = e.getOwnerDocument();
if (doc == null)
return defValue;
Resources bundle = (Resources) resourceMap.get(doc);
if (bundle == null)
return defValue;
resName = resName.replace(' ', '_');
try {
return resolveMetaReferences(bundle.getString(resName));
} catch (MissingResourceException mre) {
}
return defValue;
}
use of java.util.MissingResourceException in project processdash by dtuma.
the class TeamMemberListMergeConflictNotificationFactory method create.
public static MergeConflictNotification create(TeamMemberListMerger merger, MergeWarning<Integer> mw) {
MergeConflictNotification result = new MergeConflictNotification(ModelType.TeamList, mw);
result.putNodeAttributes(merger.main.findTeamMemberByID(mw.getMainNodeID()), merger.incoming.findTeamMemberByID(mw.getIncomingNodeID()));
result.addUserOption(MergeConflictNotification.DISMISS, null);
try {
result.formatDescription();
return result;
} catch (MissingResourceException mre) {
System.err.println("Unexpected merge conflict key for " + "team member list: " + mre.getKey());
return null;
}
}
use of java.util.MissingResourceException in project processdash by dtuma.
the class TinyCGIBase method parseResourceFile.
protected void parseResourceFile(String context, String filename) throws IOException {
String bundleName = resolveRelativeURI(context, filename);
int pos = bundleName.indexOf("//");
if (pos != -1)
bundleName = bundleName.substring(pos + 1);
pos = bundleName.lastIndexOf('.');
if (pos != -1 && bundleName.indexOf('/', pos) == -1)
bundleName = bundleName.substring(0, pos);
try {
Resources bundle = Resources.getTemplateBundle(bundleName);
getInterpolator().addResources(bundle);
} catch (MissingResourceException mre) {
System.out.println("Couldn't find resource file: " + bundleName);
System.out.println("(Specified as '" + filename + "' from '" + context + "')");
}
}
use of java.util.MissingResourceException in project uPortal by Jasig.
the class XmlChannelPublishingDefinitionDao method loadChannelPublishingDefinition.
private PortletPublishingDefinition loadChannelPublishingDefinition(int channelTypeId) {
// if the CPD is not already in the cache, determine the CPD URI
final String cpdUri;
if (channelTypeId >= 0) {
final IPortletType type = this.portletTypeRegistry.getPortletType(channelTypeId);
if (type == null) {
throw new IllegalArgumentException("No ChannelType registered with id: " + channelTypeId);
}
cpdUri = type.getCpdUri();
} else {
throw new IllegalArgumentException("No ChannelType registered with id: " + channelTypeId);
}
// read and parse the CPD
final PortletPublishingDefinition def;
final Resource cpdResource = this.resourceLoader.getResource("classpath:" + cpdUri);
if (!cpdResource.exists()) {
throw new MissingResourceException("Failed to find CPD '" + cpdUri + "' for channel type " + channelTypeId, this.getClass().getName(), cpdUri);
}
final InputStream cpdStream;
try {
cpdStream = cpdResource.getInputStream();
} catch (IOException e) {
throw new MissingResourceException("Failed to load CPD '" + cpdUri + "' for channel type " + channelTypeId, this.getClass().getName(), cpdUri);
}
try {
def = (PortletPublishingDefinition) this.unmarshaller.unmarshal(cpdStream);
final List<Step> sharedParameters = this.getSharedParameters();
def.getSteps().addAll(sharedParameters);
// add the CPD to the cache and return it
this.cpdCache.put(channelTypeId, def);
return def;
} catch (JAXBException e) {
} finally {
IOUtils.closeQuietly(cpdStream);
}
return null;
}
Aggregations