Search in sources :

Example 1 with BranchToExistingProjectDatabaseAction

use of org.bimserver.database.actions.BranchToExistingProjectDatabaseAction in project BIMserver by opensourceBIM.

the class ServiceImpl method branchToExistingProject.

@Override
public Long branchToExistingProject(Long roid, Long destPoid, String comment, Boolean sync) throws UserException, ServerException {
    requireRealUserAuthentication();
    final DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        BranchToExistingProjectDatabaseAction action = new BranchToExistingProjectDatabaseAction(session, getInternalAccessMethod(), getBimServer(), getAuthorization(), roid, destPoid, comment);
        User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        String username = user.getName();
        String userUsername = user.getUsername();
        LongBranchAction longBranchAction = new LongBranchAction(getBimServer(), username, userUsername, getAuthorization(), action);
        getBimServer().getLongActionManager().start(longBranchAction);
        if (sync) {
            longBranchAction.waitForCompletion();
        }
        return longBranchAction.getProgressTopic().getKey().getId();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : LongBranchAction(org.bimserver.longaction.LongBranchAction) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) BranchToExistingProjectDatabaseAction(org.bimserver.database.actions.BranchToExistingProjectDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)1 MessagingException (javax.mail.MessagingException)1 AddressException (javax.mail.internet.AddressException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 BranchToExistingProjectDatabaseAction (org.bimserver.database.actions.BranchToExistingProjectDatabaseAction)1 SUser (org.bimserver.interfaces.objects.SUser)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 LongBranchAction (org.bimserver.longaction.LongBranchAction)1 User (org.bimserver.models.store.User)1 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)1 SerializerException (org.bimserver.plugins.serializers.SerializerException)1 PluginException (org.bimserver.shared.exceptions.PluginException)1 ServerException (org.bimserver.shared.exceptions.ServerException)1 ServiceException (org.bimserver.shared.exceptions.ServiceException)1 UserException (org.bimserver.shared.exceptions.UserException)1 BcfException (org.opensourcebim.bcf.BcfException)1