use of org.glassfish.config.support.Create in project Payara by payara.
the class TemplateListOfResource method getPostCommand.
/**
* allows for remote files to be put in a tmp area and we pass the
* local location of this file to the corresponding command instead of the content of the file
* * Yu need to add enctype="multipart/form-data" in the form
* for ex: <form action="http://localhost:4848/management/domain/applications/application" method="post" enctype="multipart/form-data">
* then any param of type="file" will be uploaded, stored locally and the param will use the local location
* on the server side (ie. just the path)
*/
public String getPostCommand() {
ConfigModel.Property p = parent.model.getElement(tagName);
if (p == null) {
// "*"
ConfigModel.Property childElement = parent.model.getElement("*");
if (childElement != null) {
ConfigModel.Node node = (ConfigModel.Node) childElement;
ConfigModel childModel = node.getModel();
List<ConfigModel> subChildConfigModels = ResourceUtil.getRealChildConfigModels(childModel, parent.document);
for (ConfigModel subChildConfigModel : subChildConfigModels) {
if (subChildConfigModel.getTagName().equals(tagName)) {
return ResourceUtil.getCommand(RestRedirect.OpType.POST, subChildConfigModel);
}
}
}
} else {
ConfigModel.Node n = (ConfigModel.Node) p;
String command = ResourceUtil.getCommand(RestRedirect.OpType.POST, n.getModel());
if (command != null) {
return command;
}
// last possible case...the @Create annotation on a parent method
Class<? extends ConfigBeanProxy> cbp = null;
try {
cbp = (Class<? extends ConfigBeanProxy>) parent.model.classLoaderHolder.loadClass(parent.model.targetTypeName);
} catch (MultiException e) {
//
return null;
}
Create create = null;
for (Method m : cbp.getMethods()) {
ConfigModel.Property pp = parent.model.toProperty(m);
if ((pp != null) && (pp.xmlName.equals(tagName)) && (m.isAnnotationPresent(Create.class))) {
create = m.getAnnotation(Create.class);
break;
}
}
if (create != null) {
return create.value();
}
}
return null;
}
Aggregations