use of com.servoy.j2db.persistence.IRootObject in project servoy-client by Servoy.
the class SharedMediaResource method getResource.
private ResourceState getResource(final String iconId, final String solutionName) {
return new ResourceState() {
private String contentType;
private int length;
byte[] array = null;
@Override
public Time lastModifiedTime() {
try {
IRootObject solution = ApplicationServerRegistry.get().getLocalRepository().getActiveRootObject(solutionName, IRepository.SOLUTIONS);
if (solution != null)
return Time.valueOf(solution.getLastModifiedTime());
} catch (Exception e) {
Debug.trace(e);
}
return time;
}
@Override
public byte[] getData() {
if (array == null) {
boolean closeFS = false;
try {
final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
FlattenedSolution fs = null;
try {
if (Session.exists() && ((WebClientSession) Session.get()).getWebClient() != null) {
fs = ((WebClientSession) Session.get()).getWebClient().getFlattenedSolution();
}
if (fs == null) {
SolutionMetaData solutionMetaData = (SolutionMetaData) repository.getRootObjectMetaData(solutionName, IRepository.SOLUTIONS);
if (solutionMetaData == null)
return new byte[0];
closeFS = true;
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return repository;
}
});
}
Media m = fs.getMedia(iconId);
if (m == null) {
try {
Integer iIconID = new Integer(iconId);
m = fs.getMedia(iIconID.intValue());
} catch (NumberFormatException ex) {
Debug.error("no media found for: " + iconId);
}
}
if (m != null) {
array = m.getMediaData();
contentType = m.getMimeType();
}
} finally {
if (closeFS && fs != null) {
fs.close(null);
}
}
if (array != null) {
if (contentType == null) {
contentType = MimeTypes.getContentType(array);
}
length = array.length;
}
} catch (Exception ex) {
Debug.error(ex);
}
}
return array == null ? new byte[0] : array;
}
/**
* @see wicket.markup.html.DynamicWebResource.ResourceState#getLength()
*/
@Override
public int getLength() {
return length;
}
@Override
public String getContentType() {
return contentType;
}
};
}
use of com.servoy.j2db.persistence.IRootObject in project servoy-client by Servoy.
the class FlattenedSolution method getScopesPerSolution.
private Map<String, Pair<String, IRootObject>> getScopesPerSolution() {
if (mainSolution == null && loginFlattenedSolution != null) {
return loginFlattenedSolution.getScopesPerSolution();
}
Map<String, Pair<String, IRootObject>> scopes = new HashMap<String, Pair<String, IRootObject>>();
if (mainSolution != null) {
for (String scopeName : mainSolution.getScopeNames()) {
scopes.put(scopeName, new Pair<String, IRootObject>(scopeName, mainSolution));
}
if (modules != null) {
for (Solution s : modules) {
if (s != mainSolution) {
for (String scopeName : s.getScopeNames()) {
if (!scopes.containsKey(scopeName)) {
// TODO: check if same scope exists with different modules
scopes.put(scopeName, new Pair<String, IRootObject>(scopeName, s));
}
}
}
}
}
}
addGlobalsScope(scopes);
return scopes;
}
Aggregations