Search in sources :

Example 1 with LongBranchAction

use of org.bimserver.longaction.LongBranchAction in project BIMserver by opensourceBIM.

the class ServiceImpl method branchToNewProject.

@Override
public Long branchToNewProject(Long roid, String projectName, String comment, Boolean sync) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BranchToNewProjectDatabaseAction action = new BranchToNewProjectDatabaseAction(session, getInternalAccessMethod(), getBimServer(), getAuthorization(), roid, projectName, comment);
        User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        String username = user.getName();
        String userUsername = user.getUsername();
        LongBranchAction longAction = new LongBranchAction(getBimServer(), username, userUsername, getAuthorization(), action);
        getBimServer().getLongActionManager().start(longAction);
        if (sync) {
            longAction.waitForCompletion();
        }
        return longAction.getProgressTopic().getKey().getId();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : BranchToNewProjectDatabaseAction(org.bimserver.database.actions.BranchToNewProjectDatabaseAction) LongBranchAction(org.bimserver.longaction.LongBranchAction) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) 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) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 2 with LongBranchAction

use of org.bimserver.longaction.LongBranchAction 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();
    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) 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) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

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