use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.
the class CatalogTest method createRepository.
private RepositoryEntry createRepository(String displayName, final Long resourceableId) {
OLATResourceable resourceable = new OLATResourceable() {
public String getResourceableTypeName() {
return CourseModule.ORES_TYPE_COURSE;
}
public Long getResourceableId() {
return resourceableId;
}
};
OLATResourceManager rm = OLATResourceManager.getInstance();
// create course and persist as OLATResourceImpl
OLATResource r = rm.findResourceable(resourceable);
if (r == null) {
r = rm.createOLATResourceInstance(resourceable);
}
DBFactory.getInstance().saveObject(r);
DBFactory.getInstance().intermediateCommit();
RepositoryEntry d = RepositoryManager.getInstance().lookupRepositoryEntry(resourceable, false);
if (d == null) {
d = repositoryService.create("Rei Ayanami", "-", displayName, "Repo entry", r);
DBFactory.getInstance().saveObject(d);
}
DBFactory.getInstance().intermediateCommit();
return d;
}
use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.
the class SharedFolderManager method createSharedFolder.
public SharedFolderFileResource createSharedFolder() {
SharedFolderFileResource resource = new SharedFolderFileResource();
VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
if (rootContainer.createChildContainer(FOLDER_NAME) == null)
return null;
OLATResourceManager rm = OLATResourceManager.getInstance();
OLATResource ores = rm.createOLATResourceInstance(resource);
rm.saveOLATResource(ores);
return resource;
}
use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.
the class JunitTestHelper method createAndPersistRepositoryEntry.
public static final RepositoryEntry createAndPersistRepositoryEntry(String initialAuthor, boolean membersOnly) {
OLATResourceManager resourceManager = OLATResourceManager.getInstance();
String resourceName = UUID.randomUUID().toString().replace("-", "").substring(0, 30);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(resourceName, CodeHelper.getForeverUniqueID());
OLATResource r = resourceManager.createOLATResourceInstance(ores);
resourceManager.saveOLATResource(r);
return createAndPersistRepositoryEntry(initialAuthor, r, membersOnly);
}
use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementWebService method putEfficiencyStatement.
/**
* Create a new efficiency statement.
*
* @response.representation.200.doc If the statement was persisted
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The identity or the resource cannot be found
* @param identityKey The owner of the certificate
* @param resourceKey The primary key of the resource of the repository entry of the course.
* @return Nothing special
*/
@PUT
@Path("{identityKey}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response putEfficiencyStatement(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, EfficiencyStatementVO efficiencyStatementVO, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
if (assessedIdentity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
EfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByResourceKey(resourceKey, assessedIdentity);
if (efficiencyStatement != null) {
return Response.serverError().status(Response.Status.CONFLICT).build();
}
Date creationDate = efficiencyStatementVO.getCreationDate();
Float score = efficiencyStatementVO.getScore();
Boolean passed = efficiencyStatementVO.getPassed();
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceById(resourceKey);
if (resource == null) {
String courseTitle = efficiencyStatementVO.getCourseTitle();
efficiencyStatementManager.createStandAloneUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resourceKey, courseTitle);
} else {
efficiencyStatementManager.createUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resource);
}
return Response.ok().build();
}
use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.
the class CertificationWebService method deleteCertificateInfo.
@DELETE
@Path("{identityKey}")
public Response deleteCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity identity = baseSecurity.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceable(courseOres);
if (resource == null) {
resource = resourceManager.findResourceById(resourceKey);
}
if (resource == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
if (certificate == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
certificatesManager.deleteCertificate(certificate);
return Response.ok().build();
}
Aggregations