Created
April 9, 2014 05:45
-
-
Save DemkaAge/10229435 to your computer and use it in GitHub Desktop.
Простой бин с сессионным подключением к FN. Работает "а-ля" сервис. Под сервисной учеткой.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.brbpm.lecm.server.samples; | |
import com.filenet.api.constants.*; | |
import com.filenet.api.core.*; | |
import com.filenet.api.util.ConfigurationParameters; | |
import ru.brbpm.lecm.shared.api.ConfigServiceLocal; | |
import ru.brbpm.lecm.shared.constants.ConnectionConstants; | |
import ru.brbpm.lecm.utils.server.ejb.ServiceInterceptor; | |
import javax.annotation.PostConstruct; | |
import javax.annotation.Resource; | |
import javax.annotation.security.DeclareRoles; | |
import javax.annotation.security.RolesAllowed; | |
import javax.annotation.security.RunAs; | |
import javax.ejb.EJB; | |
import javax.ejb.SessionContext; | |
import javax.ejb.Stateless; | |
import javax.interceptor.Interceptors; | |
/** | |
* Created by dshahovkin on 07.04.2014. =D | |
*/ | |
@DeclareRoles({"ConfigServiceReader", "Users"}) | |
@RolesAllowed({"ConfigServiceReader", "Users"}) | |
@RunAs("ConfigServiceReader") | |
@Interceptors({ServiceInterceptor.class}) | |
@Stateless | |
public class FnServiceImpl implements FnServiceLocal, FnServiceRemote { | |
@Resource | |
private SessionContext context; | |
@EJB | |
private ConfigServiceLocal configServiceLocal; | |
private Connection connection; | |
@PostConstruct | |
public void init() { | |
ConfigurationParameters configurationParameter = new ConfigurationParameters(); | |
configurationParameter.setParameter(ConfigurationParameter.CONNECTION_PARTICIPATES_IN_TRANSACTION, true); | |
connection = Factory.Connection.getConnection(configServiceLocal.getProperty(ConnectionConstants | |
.CE_URI), configurationParameter); | |
} | |
@Override | |
public Document createDocument(Folder folder) { | |
Document document = Factory.Document.createInstance(folder.getObjectStore(), "Document"); | |
document.save(RefreshMode.REFRESH); | |
// Check in the document | |
document.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION); | |
document.save(RefreshMode.NO_REFRESH); | |
ReferentialContainmentRelationship rcr = folder.file(document, | |
AutoUniqueName.AUTO_UNIQUE, "New Document via Java API", | |
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); | |
rcr.save(RefreshMode.NO_REFRESH); | |
return document; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment