}
return null;
}
String projectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectName);
JSONObject jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, projectId);
ProjectInfo projectInfo = new ProjectInfo();
if (jsonObject == null) {
if (SimpleMetaStoreUtil.isMetaFolder(workspaceMetaFolder, projectId) && !SimpleMetaStoreUtil.isMetaFile(userMetaFolder, projectId)) {
// the project folder exists but the project json file does not, so create it
File projectMetaFolder = SimpleMetaStoreUtil.readMetaFolder(workspaceMetaFolder, projectId);
Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
if (logger.isDebugEnabled()) {
logger.info("SimpleMetaStore.readProject: the project folder " + projectMetaFolder.toString() + " exists but the project json file does not, so creating it in " + workspaceId); //$NON-NLS-1$
}
URI projectLocation = projectMetaFolder.toURI();
projectInfo.setFullName(projectName);
projectInfo.setWorkspaceId(workspaceId);
projectInfo.setContentLocation(projectLocation);
createProject(projectInfo);
jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, projectId);
} else {
// both the project folder and project json do not exist, no project
// OR both the project folder and project json exist, but bad project JSON file == no project
return null;
}
}
try {
projectInfo.setUniqueId(jsonObject.getString(MetadataInfo.UNIQUE_ID));
projectInfo.setWorkspaceId(jsonObject.getString("WorkspaceId"));
projectInfo.setFullName(jsonObject.getString(UserConstants2.FULL_NAME));
if (jsonObject.has("ContentLocation")) {
String decodedContentLocation = SimpleMetaStoreUtil.decodeProjectContentLocation(jsonObject.getString("ContentLocation"));
projectInfo.setContentLocation(new URI(decodedContentLocation));
}
setProperties(projectInfo, jsonObject.getJSONObject("Properties"));
projectInfo.flush();
} catch (JSONException e) {
throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readProject: could not read project " + projectName + " for userId " + userId, e));
} catch (URISyntaxException e) {
throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readProject: could not read project " + projectName + " for userId " + userId, e));
}